<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>

  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">






  
  
    
      
    
    
      
    
  <script async src="//cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>
  <link href="//cdn.jsdelivr.net/npm/pace-js@1.0.2/themes/blue/pace-theme-minimal.css" rel="stylesheet">








<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />


















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />


<link href="https://fonts.loli.net/css?family=EB+Garamond:400,400i,700,700i|Noto+Serif+SC:400,500,700&display=swap&subset=chinese-simplified" rel="stylesheet">




  

<link href="//cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/blog/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Android,开源框架,技术选型," />





  <link rel="alternate" href="/blog/atom.xml" title="叶金诚的站点" type="application/atom+xml" />






<meta name="description" content="组件化基本概念#典型的安卓工程目录结构如下，我们将根据图例介绍基本的概念术语，下文不再重复解释概念术语的含义。                       图1-典型安卓工程目录             灰色区域是工程根目录，根目录通常代指灰色区域    名称 用途    settings.gradle 用于指示 Gradle 在构建应用时应将哪些模块包含在内多模块项目需要指定应包含在最终 bui">
<meta property="og:type" content="article">
<meta property="og:title" content="Android组件化实践指南">
<meta property="og:url" content="http://idolcoder.gitee.io/blog/2021/01/Android-component-Practice-Guide/index.html">
<meta property="og:site_name" content="叶金诚的站点">
<meta property="og:description" content="组件化基本概念#典型的安卓工程目录结构如下，我们将根据图例介绍基本的概念术语，下文不再重复解释概念术语的含义。                       图1-典型安卓工程目录             灰色区域是工程根目录，根目录通常代指灰色区域    名称 用途    settings.gradle 用于指示 Gradle 在构建应用时应将哪些模块包含在内多模块项目需要指定应包含在最终 bui">
<meta property="og:locale">
<meta property="og:image" content="https://developer.android.google.cn/images/tools/studio/project-structure_2x.png?hl=zh_cn">
<meta property="og:image" content="c:/Users/20110718/AppData/Roaming/Typora/typora-user-images/image-20210608181849470.png">
<meta property="og:image" content="http://cdn.yangchaofan.cn/typora/image-20210608182147783.png">
<meta property="og:image" content="http://cdn.yangchaofan.cn/typora/image-20210608182703542.png">
<meta property="og:image" content="http://cdn.yangchaofan.cn/typora/image-20210608182315991.png">
<meta property="og:image" content="http://cdn.yangchaofan.cn/typora/image-20210608182509726.png">
<meta property="og:image" content="https://raw.githubusercontent.com/JessYanCoding/ArmsComponent/master/arts/ArmsComponentArchitecture.jpeg">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/6650461-92c8e8a0a078f6ef.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/563/format/webp">
<meta property="article:published_time" content="2021-01-17T12:31:06.000Z">
<meta property="article:modified_time" content="2021-06-10T15:11:10.345Z">
<meta property="article:author" content="叶金诚">
<meta property="article:tag" content="Android">
<meta property="article:tag" content="开源框架">
<meta property="article:tag" content="技术选型">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://developer.android.google.cn/images/tools/studio/project-structure_2x.png?hl=zh_cn">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":true,"onmobile":true},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":true,"transition":{"post_block":"flipBounceYIn","post_header":"perspectiveRightIn","post_body":"fadeIn","coll_header":"swoopIn","sidebar":"shrinkIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://idolcoder.gitee.io/blog/2021/01/Android-component-Practice-Guide/"/>





<!-- 设置文章需要密码访问 -->
<script>
    (function(){
        if(''){
            if (prompt('请输入文章密码') !== ''){
                alert('密码错误！');
                history.back();
            }
        }
    })();
</script>

  <title>Android组件化实践指南 | 叶金诚的站点</title>
  









  

  
	<!-- leafacePlayer -->
	
      <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
      <meta name="baidu-site-verification" content="code-lde50FghqK" />

	

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <!--fork me from github-->
    <a target="_blank" rel="noopener" href="https://github.com/ShaunSheep" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#64CEAA; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">叶金诚的站点</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <h1 class="site-subtitle" itemprop="description">汇贤雅叙</h1>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-movies">
          <a href="/blog/movies/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-film"></i> <br />
            
            电影
          </a>
        </li>
      
        
        <li class="menu-item menu-item-图书">
          <a href="/blog/books/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-calendar"></i> <br />
            
            图书
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-question-circle"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-links">
          <a href="/blog/links/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-link"></i> <br />
            
            友链
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/blog/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>


 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://idolcoder.gitee.io/blog/blog/2021/01/Android-component-Practice-Guide/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/head.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="叶金诚的站点">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">Android组件化实践指南</h2>
        

        <div class="post-meta">
          <span class="post-time">

             

             

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2021-01-17T20:31:06+08:00">
                2021-01-17
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/Android/" itemprop="url" rel="index">
                    <span itemprop="name">Android</span>
                  </a>
                </span>

                
                
                  ， 
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/Android/%E9%A1%B9%E7%9B%AE%E6%9E%B6%E6%9E%84/" itemprop="url" rel="index">
                    <span itemprop="name">项目架构</span>
                  </a>
                </span>

                
                
                  ， 
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/Android/%E5%BC%80%E6%BA%90%E6%A1%86%E6%9E%B6/" itemprop="url" rel="index">
                    <span itemprop="name">开源框架</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/blog/2021/01/Android-component-Practice-Guide/" class="leancloud_visitors" data-flag-title="Android组件化实践指南">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">浏览&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          <!--
          
          -->

          
            <span class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数&#58;</span>
                
                <span title="字数">
                  8.1k
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">时长 &asymp;</span>
                
                <span title="时长">
                  36 分钟
                </span>
              
            </span>
          

          <!-- 隐藏文章内标题下，内容描述
          
          -->

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><h1 id="组件化基本概念"><a href="#组件化基本概念" class="headerlink" title="组件化基本概念"></a>组件化基本概念<a href="#组件化基本概念" class="header-anchor">#</a></h1><p>典型的安卓工程目录结构如下，我们将根据图例介绍基本的概念术语，下文不再重复解释概念术语的含义。</p>
<center>
    <img style="border-radius: 0.3125em;
    box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="https://developer.android.google.cn/images/tools/studio/project-structure_2x.png?hl=zh_cn" width="40%" alt>
    <br>
    <div style="color:orange; border-bottom: 1px solid #d9d9d9;
    display: inline-block;
    color: #999;
    padding: 2px;">
      图1-典型安卓工程目录
      </div>
</center>



<ul>
<li><p>灰色区域是工程根目录，根目录通常代指灰色区域</p>
<table>
<thead>
<tr>
<th>名称</th>
<th>用途</th>
</tr>
</thead>
<tbody><tr>
<td>settings.gradle</td>
<td>用于指示 Gradle 在构建应用时应将哪些模块包含在内<br>多模块项目需要指定应包含在最终 build 中的每个模块</td>
</tr>
<tr>
<td>顶层build.gradle</td>
<td>用于定义项目中所有模块的构建配置<br><code>buildscript</code> 代码块定义项目中所有模块共用的 <code>Gradle</code> 代码库和依赖项<br></td>
</tr>
<tr>
<td>gradle属性文件</td>
<td><code>gradle.properties</code>和<code>local.properties</code></td>
</tr>
</tbody></table>
</li>
</ul>
<ul>
<li><p>绿色区域是module目录，模块目录通知代指绿色区域</p>
<table>
<thead>
<tr>
<th>名称</th>
<th>用途</th>
</tr>
</thead>
<tbody><tr>
<td>模块级build.gradle</td>
<td>为其所在的特定模块配置构建设置<br>自定义打包选项（如额外的构建类型和产品变种）<br>替换 <code>main/ AndroidManifest.xml</code>或<code>顶层 build.gradle</code> 文件中的设置</td>
</tr>
</tbody></table>
</li>
</ul>
<ul>
<li><p>蓝色区域是源代码集<sup id="fnref:3"><a href="#fn:3" rel="footnote"><span class="hint--top hint--error hint--medium hint--rounded hint--bounce" aria-label="[配置构建  | Android 开发者  | Android Developers (google.cn)](https://developer.android.google.cn/studio/build?hl=zh_cn#sourcesets)
">[3]</span></a></sup></p>
<table>
<thead>
<tr>
<th>名称</th>
<th>用途</th>
</tr>
</thead>
<tbody><tr>
<td>src/main/</td>
<td>此源代码集包含所有构建变体共用的代码和资源。</td>
</tr>
<tr>
<td>src/buildType/</td>
<td>创建此源代码集可加入特定构建变体专用的代码和资源。</td>
</tr>
<tr>
<td>src/productFlavor/</td>
<td>创建此源代码集可加入特定产品变种专用的代码和资源。<br><strong>注意</strong>：如果配置构建以<a target="_blank" rel="noopener" href="https://developer.android.google.cn/studio/build/build-variants?hl=zh_cn#flavor-dimensions">组合多个产品变种</a>，则可以为变种维度之间的每个产品变种组合创建源代码集目录：<code>src/productFlavor1ProductFlavor2/</code></td>
</tr>
<tr>
<td>src/productFlavorBuildType/</td>
<td>创建此源代码集可加入特定构建变体专用的代码和资源。</td>
</tr>
</tbody></table>
</li>
</ul>
<h2 id="gradle属性文件"><a href="#gradle属性文件" class="headerlink" title="gradle属性文件"></a>gradle属性文件<a href="#gradle属性文件" class="header-anchor">#</a></h2><h3 id="gradleproperties"><a href="#gradle-properties" class="headerlink" title="gradle.properties"></a>gradle.properties<a href="#gradleproperties" class="header-anchor">#</a></h3><p>配置项目全局 Gradle 设置，如 Gradle 守护程序的最大堆大小。如需了解详情，请参阅<a target="_blank" rel="noopener" href="https://docs.gradle.org/current/userguide/build_environment.html">构建环境</a></p>
<h3 id="localproperties"><a href="#local-properties" class="headerlink" title="local.properties"></a>local.properties<a href="#localproperties" class="header-anchor">#</a></h3><p>为构建系统配置本地环境属性，其中包括：</p>
<ul>
<li><code>ndk.dir</code> - NDK 的路径。此属性已被弃用。NDK 的所有下载版本都将安装在 Android SDK 目录下的 <code>ndk</code> 目录中。</li>
<li><code>sdk.dir</code> - SDK 的路径。</li>
<li><code>cmake.dir</code> - CMake 的路径。</li>
<li><code>ndk.symlinkdir</code> - 在 Android Studio 3.5 及更高版本中，创建指向 NDK 的符号链接，该符号链接的路径可比 NDK 安装路径短</li>
</ul>
<h2 id="顶层buildgradle"><a href="#顶层build-gradle" class="headerlink" title="顶层build.gradle"></a>顶层build.gradle<a href="#顶层buildgradle" class="header-anchor">#</a></h2><p><code>顶层build.gradle</code>用途是配置项目全局属性：有两种配置方式直接配置和外部导入</p>
<h3 id="直接配置"><a href="#直接配置" class="headerlink" title="直接配置"></a>直接配置<a href="#直接配置" class="header-anchor">#</a></h3><p>直接在<code>顶层build.gradle</code>形式写入配置<code>ext&#123;&#125;</code></p>
<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="GROOVY"><figure class="iseeu highlight /groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">buildscript &#123;...&#125;</span><br><span class="line">allprojects &#123;...&#125;</span><br><span class="line">ext &#123;</span><br><span class="line">    sdkVersion = <span class="number">28</span></span><br><span class="line">    supportLibVersion = <span class="string">&quot;28.0.0&quot;</span></span><br><span class="line">    ...</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure></div>
<h3 id="外部导入"><a href="#外部导入" class="headerlink" title="外部导入"></a>外部导入<a href="#外部导入" class="header-anchor">#</a></h3><p>在根目录下 定义config.gradle文件，写入配置<code>ext&#123;&#125;</code>，接着在顶级build.gradle中导入该配置</p>
<p>第一步：创建<code>根目录/config.gradle</code>文件，并编写配置</p>
<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="GROOVY"><figure class="iseeu highlight /groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br></pre></td><td class="code"><pre><span class="line">ext &#123;</span><br><span class="line">    <span class="comment">//android开发版本配置</span></span><br><span class="line">    android = [</span><br><span class="line">            <span class="symbol">compileSdkVersion:</span> <span class="number">28</span>,</span><br><span class="line">            <span class="symbol">buildToolsVersion:</span> <span class="string">&quot;28.0.0&quot;</span>,</span><br><span class="line">            <span class="attr">applicationId    :</span> <span class="string">&quot;com.fly.tour&quot;</span>,</span><br><span class="line">            <span class="attr">minSdkVersion    :</span> <span class="number">15</span>,</span><br><span class="line">            <span class="attr">targetSdkVersion :</span> <span class="number">28</span>,</span><br><span class="line">            <span class="attr">versionCode      :</span> <span class="number">1</span>,</span><br><span class="line">            <span class="attr">versionName      :</span> <span class="string">&quot;1.0&quot;</span>,</span><br><span class="line">    ]</span><br><span class="line">    <span class="comment">//version配置</span></span><br><span class="line">    versions = [</span><br><span class="line">            <span class="string">&quot;support-version&quot;</span>: <span class="string">&quot;28.0.0&quot;</span>,</span><br><span class="line">            <span class="string">&quot;junit-version&quot;</span>  : <span class="string">&quot;4.12&quot;</span>,</span><br><span class="line">    ]</span><br><span class="line">    <span class="comment">//support配置</span></span><br><span class="line">    support = [</span><br><span class="line">            <span class="string">&quot;constraint-layout&quot;</span>       : <span class="string">&quot;2.0.4&quot;</span>,</span><br><span class="line">            <span class="string">&#x27;support-v4&#x27;</span>              : <span class="string">&quot;com.android.support:support-v4:$&#123;versions[&quot;</span>support-version<span class="string">&quot;]&#125;&quot;</span>,</span><br><span class="line">            <span class="string">&#x27;appcompat-v7&#x27;</span>            : <span class="string">&quot;com.android.support:appcompat-v7:$&#123;versions[&quot;</span>support-version<span class="string">&quot;]&#125;&quot;</span>,</span><br><span class="line">            <span class="string">&#x27;recyclerview-v7&#x27;</span>         : <span class="string">&quot;com.android.support:recyclerview-v7:$&#123;versions[&quot;</span>support-version<span class="string">&quot;]&#125;&quot;</span>,</span><br><span class="line">            <span class="string">&#x27;support-v13&#x27;</span>             : <span class="string">&quot;com.android.support:support-v13:$&#123;versions[&quot;</span>support-version<span class="string">&quot;]&#125;&quot;</span>,</span><br><span class="line">            <span class="string">&#x27;support-fragment&#x27;</span>        : <span class="string">&quot;com.android.support:support-fragment:$&#123;versions[&quot;</span>support-version<span class="string">&quot;]&#125;&quot;</span>,</span><br><span class="line">            <span class="string">&#x27;design&#x27;</span>                  : <span class="string">&quot;com.android.support:design:$&#123;versions[&quot;</span>support-version<span class="string">&quot;]&#125;&quot;</span>,</span><br><span class="line">            <span class="string">&#x27;animated-vector-drawable&#x27;</span>: <span class="string">&quot;com.android.support:animated-vector-drawable:$&#123;versions[&quot;</span>support-version<span class="string">&quot;]&#125;&quot;</span>,</span><br><span class="line">            <span class="string">&#x27;junit&#x27;</span>                   : <span class="string">&quot;junit:junit:$&#123;versions[&quot;</span>junit-version<span class="string">&quot;]&#125;&quot;</span>,</span><br><span class="line">    ]</span><br><span class="line">    <span class="comment">//依赖第三方配置</span></span><br><span class="line">    dependencies = [</span><br><span class="line">            <span class="comment">//rxjava</span></span><br><span class="line">            <span class="string">&quot;rxjava&quot;</span>                               : <span class="string">&quot;io.reactivex.rxjava2:rxjava:2.2.3&quot;</span>,</span><br><span class="line">            <span class="string">&quot;rxandroid&quot;</span>                            : <span class="string">&quot;io.reactivex.rxjava2:rxandroid:2.1.0&quot;</span>,</span><br><span class="line">            <span class="comment">//rx系列与View生命周期同步</span></span><br><span class="line">            <span class="string">&quot;rxlifecycle&quot;</span>                          : <span class="string">&quot;com.trello.rxlifecycle2:rxlifecycle:2.2.2&quot;</span>,</span><br><span class="line">            <span class="string">&quot;rxlifecycle-components&quot;</span>               : <span class="string">&quot;com.trello.rxlifecycle2:rxlifecycle-components:2.2.2&quot;</span>,</span><br><span class="line">            <span class="comment">//rxbinding</span></span><br><span class="line">            <span class="string">&quot;rxbinding&quot;</span>                            : <span class="string">&quot;com.jakewharton.rxbinding2:rxbinding:2.1.1&quot;</span>,</span><br><span class="line">            <span class="comment">//rx 6.0权限请求</span></span><br><span class="line">            <span class="string">&quot;rxpermissions&quot;</span>                        : <span class="string">&quot;com.github.tbruyelle:rxpermissions:0.10.2&quot;</span>,</span><br><span class="line">            <span class="comment">//network</span></span><br><span class="line">            <span class="string">&quot;okhttp&quot;</span>                               : <span class="string">&quot;com.squareup.okhttp3:okhttp:3.10.0&quot;</span>,</span><br><span class="line">            <span class="string">&quot;retrofit&quot;</span>                             : <span class="string">&quot;com.squareup.retrofit2:retrofit:2.4.0&quot;</span>,</span><br><span class="line">            <span class="string">&quot;converter-gson&quot;</span>                       : <span class="string">&quot;com.squareup.retrofit2:converter-gson:2.4.0&quot;</span>,</span><br><span class="line">            <span class="string">&quot;adapter-rxjava&quot;</span>                       : <span class="string">&quot;com.squareup.retrofit2:adapter-rxjava2:2.4.0&quot;</span>,</span><br><span class="line">            <span class="string">&quot;logging-interceptor&quot;</span>                  : <span class="string">&quot;com.squareup.okhttp3:logging-interceptor:3.9.1&quot;</span>,</span><br><span class="line"></span><br><span class="line">            <span class="comment">//glide图片加载</span></span><br><span class="line">            <span class="string">&quot;glide&quot;</span>                                : <span class="string">&quot;com.github.bumptech.glide:glide:4.8.0&quot;</span>,</span><br><span class="line">            <span class="string">&quot;glide-compiler&quot;</span>                       : <span class="string">&quot;com.github.bumptech.glide:compiler:4.8.0&quot;</span>,</span><br><span class="line">            <span class="comment">//json解析</span></span><br><span class="line">            <span class="string">&quot;gson&quot;</span>                                 : <span class="string">&quot;com.google.code.gson:gson:2.8.5&quot;</span>,</span><br><span class="line"></span><br><span class="line">            <span class="comment">//Google AAC</span></span><br><span class="line">            <span class="string">&quot;lifecycle-extensions&quot;</span>                 : <span class="string">&quot;android.arch.lifecycle:extensions:1.1.1&quot;</span>,</span><br><span class="line">            <span class="string">&quot;lifecycle-compiler&quot;</span>                 : <span class="string">&quot;android.arch.lifecycle:compiler:1.1.1&quot;</span>,</span><br><span class="line">            <span class="comment">//阿里路由框架</span></span><br><span class="line">            <span class="string">&quot;arouter-api&quot;</span>                          : <span class="string">&quot;com.alibaba:arouter-api:1.4.1&quot;</span>,</span><br><span class="line">            <span class="string">&quot;arouter-compiler&quot;</span>                     : <span class="string">&quot;com.alibaba:arouter-compiler:1.2.2&quot;</span>,</span><br><span class="line">            <span class="string">&quot;eventbus&quot;</span>                             : <span class="string">&quot;org.greenrobot:eventbus:3.1.1&quot;</span>,</span><br><span class="line">            <span class="string">&quot;dagger&quot;</span>                             : <span class="string">&quot;com.google.dagger:dagger:2.13&quot;</span>,</span><br><span class="line">            <span class="string">&quot;dagger-compiler&quot;</span>                      :<span class="string">&quot;com.google.dagger:dagger-compiler:2.13&quot;</span>,</span><br><span class="line">            <span class="string">&quot;stetho&quot;</span>                               :<span class="string">&quot;com.facebook.stetho:stetho:1.3.1&quot;</span>,</span><br><span class="line">            <span class="string">&quot;MultiImageSelector&quot;</span>                   :<span class="string">&quot;com.github.lovetuzitong:MultiImageSelector:1.2&quot;</span></span><br><span class="line">    ]</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></div>
<p>第二步：在<code>顶级build.gradle</code>中导入全局配置<code>apply from: &quot;config.gradle&quot;</code></p>
<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="GROOVY"><figure class="iseeu highlight /groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">buildscript &#123;</span><br><span class="line">    repositories &#123;</span><br><span class="line">        google()</span><br><span class="line">        jcenter()</span><br><span class="line">    &#125;</span><br><span class="line">    dependencies &#123;</span><br><span class="line">        classpath <span class="string">&#x27;com.android.tools.build:gradle:3.5.0&#x27;</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">allprojects &#123;</span><br><span class="line">    repositories &#123;</span><br><span class="line">        google()</span><br><span class="line">        jcenter()</span><br><span class="line">        maven &#123; url <span class="string">&#x27;https://jitpack.io&#x27;</span> &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">task clean(<span class="attr">type:</span> Delete) &#123;</span><br><span class="line">    delete rootProject.buildDir</span><br><span class="line">&#125;</span><br><span class="line">apply <span class="attr">from:</span> <span class="string">&quot;config.gradle&quot;</span></span><br></pre></td></tr></table></figure></div>
<p>第三步：访问方式，在绿色区域代表的module区域内，有一个<code>模块级build.gradle</code>文件，在该文件内可以通过<code>rootProject.ext.property_name</code>方式访问全局配置</p>
<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="GROOVY"><figure class="iseeu highlight /groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">android &#123;</span><br><span class="line">    <span class="comment">// rootProject.ext.property_name</span></span><br><span class="line">    compileSdkVersion rootProject.ext.compileSdkVersion</span><br><span class="line">    ...</span><br><span class="line">&#125;</span><br><span class="line">...</span><br><span class="line">dependencies &#123;</span><br><span class="line">    implementation <span class="string">&quot;com.android.support:appcompat-v7:$&#123;rootProject.ext.supportLibVersion&#125;&quot;</span></span><br><span class="line">    ...</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></div>


<h2 id="模块级buildgradle"><a href="#模块级build-gradle" class="headerlink" title="模块级build.gradle"></a>模块级build.gradle<a href="#模块级buildgradle" class="header-anchor">#</a></h2><div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="GROOVY"><figure class="iseeu highlight /groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 构建配置的第一行将Gradle的Android插件应用到这个构建中，并使Android</span></span><br><span class="line"><span class="comment"> * 代码块可用来指定特定于Android的构建选项。</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line">apply <span class="attr">plugin:</span> <span class="string">&#x27;com.android.application&#x27;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * android block是你配置所有android特定构建选项的地方。</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line">android &#123;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * compileSdkVersion指定了Gradle用来编译你的应用程序的Android API级别。</span></span><br><span class="line"><span class="comment">     * 这意味着你的应用程序可以使用包含在这个API级别或更低级别的API特性。</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    compileSdkVersion <span class="number">28</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * buildToolsVersion指定了Gradle用来构建应用的SDK构建工具、命令行工具和编译器的版本。</span></span><br><span class="line"><span class="comment">     * 你需要通过SDK管理器下载构建工具。</span></span><br><span class="line"><span class="comment">     * 此属性是可选的，因为插件默认使用构建工具的推荐版本。</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    buildToolsVersion <span class="string">&quot;30.0.2&quot;</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * defaultConfig块封装了所有构建变量的默认设置和条目，</span></span><br><span class="line"><span class="comment">     * 并且可以从构建系统动态覆盖main/AndroidManifest.xml中的一些属性。</span></span><br><span class="line"><span class="comment">     * 你可以配置产品风味，以覆盖不同版本的应用程序的这些值。</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    defaultConfig &#123;</span><br><span class="line"></span><br><span class="line">        <span class="comment">/**</span></span><br><span class="line"><span class="comment">         * applicationId唯一标识要发布的包。</span></span><br><span class="line"><span class="comment">         * 但是，你的源代码仍然应该引用main/AndroidManifest.xml文件中package属性定义的包名。</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line">        applicationId <span class="string">&#x27;com.example.myapp&#x27;</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">// 定义运行应用程序所需的最低API级别。</span></span><br><span class="line">        minSdkVersion <span class="number">15</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">// 指定用于测试应用程序的API级别。</span></span><br><span class="line">        targetSdkVersion <span class="number">28</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">// 定义应用程序的版本号。</span></span><br><span class="line">        versionCode <span class="number">1</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">// 为应用程序定义一个用户友好的版本名。</span></span><br><span class="line">        versionName <span class="string">&quot;1.0&quot;</span></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * buildTypes块是您可以配置多个构建类型的地方。</span></span><br><span class="line"><span class="comment">     * 默认情况下，构建系统定义了两种构建类型:调试debug和发布release。</span></span><br><span class="line"><span class="comment">     * 调试构建类型没有在默认构建配置中显式显示，但它包括调试工具，并使用调试键进行签名。</span></span><br><span class="line"><span class="comment">     * 发布版本构建类型应用了Proguard设置，默认情况下没有签名。</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    buildTypes &#123;</span><br><span class="line"></span><br><span class="line">        <span class="comment">/**</span></span><br><span class="line"><span class="comment">         * 默认情况下，Android Studio使用minifyEnabled配置release build类型来启用代码收缩，</span></span><br><span class="line"><span class="comment">         * 并指定默认的Proguard规则文件。</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line"></span><br><span class="line">        release &#123;</span><br><span class="line">              minifyEnabled <span class="literal">true</span> <span class="comment">// 启用发布构建类型的代码收缩。</span></span><br><span class="line">              proguardFiles getDefaultProguardFile(<span class="string">&#x27;proguard-android.txt&#x27;</span>), <span class="string">&#x27;proguard-rules.pro&#x27;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 在productversions块中，您可以配置多个产品版本。</span></span><br><span class="line"><span class="comment">     * 这允许你创建不同版本的应用程序，可以用它们自己的设置覆盖defaultConfig块。</span></span><br><span class="line"><span class="comment">     * 产品样式是可选的，构建系统默认情况下不会创建它们。</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * 这个例子创建了一个免费和付费的产品风格。</span></span><br><span class="line"><span class="comment">     * 每个产品样式都指定了自己的应用程序ID，这样它们就可以同时存在于谷歌Play Store或Android设备上。</span></span><br><span class="line"><span class="comment">     * 如果声明产品风味flavors，还必须声明风味维度dimensions并将每个风味分配给风味维度dimensions。</span></span><br><span class="line"><span class="comment">     * If you declare product flavors, you must also declare flavor dimensions</span></span><br><span class="line"><span class="comment">     * and assign each flavor to a flavor dimension.</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line"></span><br><span class="line">    flavorDimensions <span class="string">&quot;tier&quot;</span></span><br><span class="line">    productFlavors &#123;</span><br><span class="line">        free &#123;</span><br><span class="line">            dimension <span class="string">&quot;tier&quot;</span></span><br><span class="line">            applicationId <span class="string">&#x27;com.example.myapp.free&#x27;</span></span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        paid &#123;</span><br><span class="line">            dimension <span class="string">&quot;tier&quot;</span></span><br><span class="line">            applicationId <span class="string">&#x27;com.example.myapp.paid&#x27;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 模块级构建配置文件中的依赖项块指定仅构建模块本身所需的依赖项。</span></span><br><span class="line"><span class="comment"> * 要了解更多信息，请转到添加构建依赖项。</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line">dependencies &#123;</span><br><span class="line">    implementation project(<span class="string">&quot;:lib&quot;</span>)</span><br><span class="line">    implementation <span class="string">&#x27;com.android.support:appcompat-v7:28.0.0&#x27;</span></span><br><span class="line">    implementation fileTree(<span class="attr">dir:</span> <span class="string">&#x27;libs&#x27;</span>, <span class="attr">include:</span> [<span class="string">&#x27;*.jar&#x27;</span>])</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></div>
<h2 id="源代码集sourceset"><a href="#源代码集Sourceset" class="headerlink" title="源代码集Sourceset"></a>源代码集Sourceset<a href="#源代码集sourceset" class="header-anchor">#</a></h2><p>在蓝色区域<sup id="fnref:3"><a href="#fn:3" rel="footnote"><span class="hint--top hint--error hint--medium hint--rounded hint--bounce" aria-label="[配置构建  | Android 开发者  | Android Developers (google.cn)](https://developer.android.google.cn/studio/build?hl=zh_cn#sourcesets)
">[3]</span></a></sup>已经描述过源代码集的4种类型，以下是四种源代码集的示例，构建系统需要<strong>合并</strong>来自以下源代码集的代码、设置和资源：</p>
<ul>
<li><code>src/fullDebug/</code>（构建变体源代码集）</li>
<li><code>src/debug/</code>（构建类型源代码集）</li>
<li><code>src/full/</code>（产品变种源代码集）</li>
<li><code>src/main/</code>（主源代码集）</li>
</ul>
<p>记住，构建系统会合并上述四种代码集，如果同一文件在上述不同源代码集有冲突，则Gradle会按照以下优先级使用该冲突的文件：</p>
<blockquote>
<p>构建变体 &gt; 构建类型 &gt; 产品变种 &gt; 主源代码集 &gt; 库依赖项</p>
<p>更多合并规则可以参考这里<sup id="fnref:4"><a href="#fn:4" rel="footnote"><span class="hint--top hint--error hint--medium hint--rounded hint--bounce" aria-label="[合并多个清单文件  | Android 开发者  | Android Developers (google.cn)](https://developer.android.google.cn/studio/build/manifest-merge?hl=zh_cn)">[4]</span></a></sup></p>
</blockquote>
<h1 id="组件化实践"><a href="#组件化实践" class="headerlink" title="组件化实践"></a>组件化实践<a href="#组件化实践" class="header-anchor">#</a></h1><h2 id="组件化目标"><a href="#组件化目标" class="headerlink" title="组件化目标"></a>组件化目标<a href="#组件化目标" class="header-anchor">#</a></h2><p>每个module可以独立运行也可以合并至某一个宿主apk</p>
<h2 id="组件化步骤"><a href="#组件化步骤" class="headerlink" title="组件化步骤"></a>组件化步骤<a href="#组件化步骤" class="header-anchor">#</a></h2><ol>
<li><p>根目录创建<code>config.gradle</code>，在里面定义数组，数组存储键值对，key是包名，value是版本</p>
</li>
<li><p>根目录创建gradle属性文件<code>module.build.gradle</code>，在里面定义所有<code>module</code>的配置，包括android类型（应用、依赖库），android属性{defaultconfi、sourcesets、buildtypes}</p>
</li>
<li><p>根目录编辑<code>gradle.properties</code>，定义<code>isComponent</code>，<code>isLibraries</code>,</p>
</li>
<li><p>处理宿主module模块，在<code>buid.gradle</code>中，根据<code>isComponent</code>属性，来决定是否引入其他组件，否则不由宿主生成apk</p>
<ol>
<li>宿主module如何引用工程根目录的<code>config.gradle</code>定义的数组答：在根目录build.gradle      加入<code> apply      from: &quot;config.gradle&quot;</code></li>
</ol>
</li>
<li><p>module模块，在<code>main/module目录</code>下创建新的<code>AndroidManifest.xml</code></p>
<ol>
<li>在新的<code>xml</code>中定义作为module启动的默认<code>Activity</code>、<code>Application</code></li>
</ol>
</li>
<li><p>module模块，在<code>main目录</code>下编辑作为非<code>Application</code>时的<code>AndroidManifest.xml</code></p>
<ol>
<li><p>在默认的<code>xml</code>中，应该删除启动的默认<code>Activity</code>、关掉<code>Application</code>的配置</p>
</li>
<li><p>作为非<code>Application</code>时，配置<code>app-name</code>有什么用？-答：可能要参考清单文件的优先级</p>
</li>
<li><p>作为非<code>Application</code>时，写的默认<code>Activity</code>有什么用？-答：参考优先级</p>
</li>
</ol>
</li>
<li><p>module模块，在<code>build.gralde</code>中，导入config.gradle，在<code>android&#123;defaultConfig</code>中，根据<code>isComponent</code>开启<code>applictionId&#125;</code>，在<code>dependecies&#123;&#125;</code>按需导入依赖库</p>
</li>
</ol>
<h2 id="根目录结构"><a href="#根目录结构" class="headerlink" title="根目录结构"></a>根目录结构<a href="#根目录结构" class="header-anchor">#</a></h2><p><img src="C:\Users\20110718\AppData\Roaming\Typora\typora-user-images\image-20210608181849470.png" alt="image-20210608181849470"></p>
<h3 id="buildgradle"><a href="#build-gradle" class="headerlink" title="build.gradle"></a>build.gradle<a href="#buildgradle" class="header-anchor">#</a></h3><div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="GROOVY"><figure class="iseeu highlight /groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// Top-level build file where you can add configuration options common to all sub-projects/modules.</span></span><br><span class="line">buildscript &#123;</span><br><span class="line">    repositories &#123;</span><br><span class="line">        google()</span><br><span class="line">        jcenter()</span><br><span class="line">    &#125;</span><br><span class="line">    dependencies &#123;</span><br><span class="line">        classpath <span class="string">&quot;com.android.tools.build:gradle:3.5.0&quot;</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">// <span class="doctag">NOTE:</span> Do not place your application dependencies here; they belong</span></span><br><span class="line">        <span class="comment">// in the individual module build.gradle files</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">allprojects &#123;</span><br><span class="line">    repositories &#123;</span><br><span class="line">        google()</span><br><span class="line">        jcenter()</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">task clean(<span class="attr">type:</span> Delete) &#123;</span><br><span class="line">    delete rootProject.buildDir</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 有什么用？</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line">apply <span class="attr">from:</span> <span class="string">&quot;config.gradle&quot;</span></span><br></pre></td></tr></table></figure></div>
<h3 id="configgradle"><a href="#config-gradle" class="headerlink" title="config.gradle"></a>config.gradle<a href="#configgradle" class="header-anchor">#</a></h3><div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="GROOVY"><figure class="iseeu highlight /groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br></pre></td><td class="code"><pre><span class="line">ext &#123;</span><br><span class="line"></span><br><span class="line">    androidinfo = [</span><br><span class="line">            <span class="symbol">compileSdkVersion:</span> <span class="number">28</span>,</span><br><span class="line">            <span class="symbol">buildToolsVersion:</span> <span class="string">&quot;28.0.0&quot;</span>,</span><br><span class="line">            <span class="attr">applicationId    :</span> <span class="string">&quot;com.fly.tour&quot;</span>,</span><br><span class="line">            <span class="attr">minSdkVersion    :</span> <span class="number">15</span>,</span><br><span class="line">            <span class="attr">targetSdkVersion :</span> <span class="number">28</span>,</span><br><span class="line">            <span class="attr">versionCode      :</span> <span class="number">1</span>,</span><br><span class="line">            <span class="attr">versionName      :</span> <span class="string">&quot;1.0&quot;</span>,</span><br><span class="line">    ]</span><br><span class="line"></span><br><span class="line">    versions = [</span><br><span class="line">            <span class="string">&quot;support-version&quot;</span> : <span class="string">&quot;28.0.0&quot;</span>,</span><br><span class="line">            <span class="string">&quot;junit-version&quot;</span>   : <span class="string">&quot;4.12&quot;</span>,</span><br><span class="line">            <span class="string">&quot;app-version-name&quot;</span>: <span class="string">&quot;20210607&quot;</span>,</span><br><span class="line">            <span class="string">&quot;app-version-code&quot;</span>: <span class="number">20210607</span>,</span><br><span class="line"></span><br><span class="line">    ]</span><br><span class="line"></span><br><span class="line">    support = [</span><br><span class="line">            <span class="string">&quot;constraint-layout&quot;</span>       : <span class="string">&quot;2.0.4&quot;</span>,</span><br><span class="line">            <span class="string">&#x27;support-v4&#x27;</span>              : <span class="string">&quot;com.android.support:support-v4:$&#123;versions[&quot;</span>support-version<span class="string">&quot;]&#125;&quot;</span>,</span><br><span class="line">            <span class="string">&#x27;appcompat-v7&#x27;</span>            : <span class="string">&quot;com.android.support:appcompat-v7:$&#123;versions[&quot;</span>support-version<span class="string">&quot;]&#125;&quot;</span>,</span><br><span class="line">            <span class="string">&#x27;recyclerview-v7&#x27;</span>         : <span class="string">&quot;com.android.support:recyclerview-v7:$&#123;versions[&quot;</span>support-version<span class="string">&quot;]&#125;&quot;</span>,</span><br><span class="line">            <span class="string">&#x27;support-v13&#x27;</span>             : <span class="string">&quot;com.android.support:support-v13:$&#123;versions[&quot;</span>support-version<span class="string">&quot;]&#125;&quot;</span>,</span><br><span class="line">            <span class="string">&#x27;support-fragment&#x27;</span>        : <span class="string">&quot;com.android.support:support-fragment:$&#123;versions[&quot;</span>support-version<span class="string">&quot;]&#125;&quot;</span>,</span><br><span class="line">            <span class="string">&#x27;design&#x27;</span>                  : <span class="string">&quot;com.android.support:design:$&#123;versions[&quot;</span>support-version<span class="string">&quot;]&#125;&quot;</span>,</span><br><span class="line">            <span class="string">&#x27;animated-vector-drawable&#x27;</span>: <span class="string">&quot;com.android.support:animated-vector-drawable:$&#123;versions[&quot;</span>support-version<span class="string">&quot;]&#125;&quot;</span>,</span><br><span class="line">            <span class="string">&#x27;junit&#x27;</span>                   : <span class="string">&quot;junit:junit:$&#123;versions[&quot;</span>junit-version<span class="string">&quot;]&#125;&quot;</span>,</span><br><span class="line">    ]</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    jetpack = [</span><br><span class="line"></span><br><span class="line">    ]</span><br><span class="line">    dependencies = [ <span class="comment">//rxjava</span></span><br><span class="line">                     <span class="string">&quot;rxjava&quot;</span>                : <span class="string">&quot;io.reactivex.rxjava2:rxjava:2.2.3&quot;</span>,</span><br><span class="line">                     <span class="string">&quot;rxandroid&quot;</span>             : <span class="string">&quot;io.reactivex.rxjava2:rxandroid:2.1.0&quot;</span>,</span><br><span class="line">                     <span class="comment">//rx系列与View生命周期同步</span></span><br><span class="line">                     <span class="string">&quot;rxlifecycle&quot;</span>           : <span class="string">&quot;com.trello.rxlifecycle2:rxlifecycle:2.2.2&quot;</span>,</span><br><span class="line">                     <span class="string">&quot;rxlifecycle-components&quot;</span>: <span class="string">&quot;com.trello.rxlifecycle2:rxlifecycle-components:2.2.2&quot;</span>,</span><br><span class="line">                     <span class="comment">//rxbinding</span></span><br><span class="line">                     <span class="string">&quot;rxbinding&quot;</span>             : <span class="string">&quot;com.jakewharton.rxbinding2:rxbinding:2.1.1&quot;</span>,</span><br><span class="line">                     <span class="comment">//rx 6.0权限请求</span></span><br><span class="line">                     <span class="string">&quot;rxpermissions&quot;</span>         : <span class="string">&quot;com.github.tbruyelle:rxpermissions:0.10.2&quot;</span>,</span><br><span class="line">                     <span class="comment">//network</span></span><br><span class="line">                     <span class="string">&quot;okhttp&quot;</span>                : <span class="string">&quot;com.squareup.okhttp3:okhttp:3.10.0&quot;</span>,</span><br><span class="line">                     <span class="string">&quot;retrofit&quot;</span>              : <span class="string">&quot;com.squareup.retrofit2:retrofit:2.4.0&quot;</span>,</span><br><span class="line">                     <span class="string">&quot;converter-gson&quot;</span>        : <span class="string">&quot;com.squareup.retrofit2:converter-gson:2.4.0&quot;</span>,</span><br><span class="line">                     <span class="string">&quot;adapter-rxjava&quot;</span>        : <span class="string">&quot;com.squareup.retrofit2:adapter-rxjava2:2.4.0&quot;</span>,</span><br><span class="line">                     <span class="string">&quot;logging-interceptor&quot;</span>   : <span class="string">&quot;com.squareup.okhttp3:logging-interceptor:3.9.1&quot;</span>,</span><br><span class="line"></span><br><span class="line">                     <span class="comment">//glide图片加载</span></span><br><span class="line">                     <span class="string">&quot;glide&quot;</span>                 : <span class="string">&quot;com.github.bumptech.glide:glide:4.8.0&quot;</span>,</span><br><span class="line">                     <span class="string">&quot;glide-compiler&quot;</span>        : <span class="string">&quot;com.github.bumptech.glide:compiler:4.8.0&quot;</span>,</span><br><span class="line">                     <span class="comment">//json解析</span></span><br><span class="line">                     <span class="string">&quot;gson&quot;</span>                  : <span class="string">&quot;com.google.code.gson:gson:2.8.5&quot;</span>,</span><br><span class="line"></span><br><span class="line">                     <span class="comment">//Google AAC</span></span><br><span class="line">                     <span class="string">&quot;lifecycle-extensions&quot;</span>  : <span class="string">&quot;android.arch.lifecycle:extensions:1.1.1&quot;</span>,</span><br><span class="line">                     <span class="string">&quot;lifecycle-compiler&quot;</span>    : <span class="string">&quot;android.arch.lifecycle:compiler:1.1.1&quot;</span>,</span><br><span class="line">                     <span class="comment">//阿里路由框架</span></span><br><span class="line">                     <span class="string">&quot;arouter-api&quot;</span>           : <span class="string">&quot;com.alibaba:arouter-api:1.4.1&quot;</span>,</span><br><span class="line">                     <span class="string">&quot;arouter-compiler&quot;</span>      : <span class="string">&quot;com.alibaba:arouter-compiler:1.2.2&quot;</span>,</span><br><span class="line">                     <span class="string">&quot;eventbus&quot;</span>              : <span class="string">&quot;org.greenrobot:eventbus:3.1.1&quot;</span>,</span><br><span class="line">                     <span class="string">&quot;dagger&quot;</span>                : <span class="string">&quot;com.google.dagger:dagger:2.13&quot;</span>,</span><br><span class="line">                     <span class="string">&quot;dagger-compiler&quot;</span>       : <span class="string">&quot;com.google.dagger:dagger-compiler:2.13&quot;</span>,</span><br><span class="line">                     <span class="string">&quot;stetho&quot;</span>                : <span class="string">&quot;com.facebook.stetho:stetho:1.3.1&quot;</span>,</span><br><span class="line">                     <span class="string">&quot;MultiImageSelector&quot;</span>    : <span class="string">&quot;com.github.lovetuzitong:MultiImageSelector:1.2&quot;</span></span><br><span class="line">    ]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></div>
<h3 id="gradle属性文件"><a href="#gradle属性文件-1" class="headerlink" title="gradle属性文件"></a>gradle属性文件<a href="#gradle属性文件" class="header-anchor">#</a></h3><div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="GROOVY"><figure class="iseeu highlight /groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">isComponent=<span class="literal">true</span></span><br><span class="line">isLib=<span class="literal">false</span></span><br></pre></td></tr></table></figure></div>
<h3 id="modulebuildgradle"><a href="#module-build-gradle" class="headerlink" title="module.build.gradle"></a>module.build.gradle<a href="#modulebuildgradle" class="header-anchor">#</a></h3><div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="GROOVY"><figure class="iseeu highlight /groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 是组件，当做Application</span></span><br><span class="line"><span class="comment"> * 不是组件，当做lib</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">if</span> (isComponent.toBoolean()) &#123;</span><br><span class="line">    apply <span class="attr">plugin:</span> <span class="string">&#x27;com.android.application&#x27;</span></span><br><span class="line">&#125; <span class="keyword">else</span> &#123;</span><br><span class="line">    apply <span class="attr">plugin:</span> <span class="string">&#x27;com.android.library&#x27;</span></span><br><span class="line">&#125;</span><br><span class="line">android &#123;</span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 编译sdk配置</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    compileSdkVersion rootProject.ext.androidinfo.compileSdkVersion</span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 每个模块的默认配置</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    defaultConfig &#123;</span><br><span class="line">        minSdkVersion rootProject.ext.androidinfo.minSdkVersion</span><br><span class="line">        targetSdkVersion rootProject.ext.androidinfo.targetSdkVersion</span><br><span class="line">        versionCode rootProject.ext.androidinfo.versionCode</span><br><span class="line">        versionName rootProject.ext.androidinfo.versionName</span><br><span class="line"></span><br><span class="line">        javaCompileOptions &#123;</span><br><span class="line">            annotationProcessorOptions &#123;</span><br><span class="line">                arguments = [<span class="attr">AROUTER_MODULE_NAME:</span> project.getName()]</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    flavorDimensions <span class="string">&quot;tier&quot;</span></span><br><span class="line">    productFlavors&#123;</span><br><span class="line">        free&#123;</span><br><span class="line">            <span class="comment">/**</span></span><br><span class="line"><span class="comment">             * 构建变体的应用ID</span></span><br><span class="line"><span class="comment">             */</span></span><br><span class="line">            applicationIdSuffix <span class="string">&quot;.free&quot;</span></span><br><span class="line">            dimension <span class="string">&quot;tier&quot;</span></span><br><span class="line">        &#125;</span><br><span class="line">        vip&#123;</span><br><span class="line">            applicationIdSuffix <span class="string">&quot;.vip&quot;</span></span><br><span class="line">            dimension <span class="string">&quot;tier&quot;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 定义源代码集默认的文件夹路径</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    sourceSets &#123;</span><br><span class="line">        androidTestDebug&#123;</span><br><span class="line">            jniLibs.srcDirs = [<span class="string">&#x27;libs&#x27;</span>]</span><br><span class="line">            <span class="keyword">if</span> (isComponent.toBoolean()) &#123;</span><br><span class="line">                <span class="comment">// 是组件，独立打包apk，读取特定的xml</span></span><br><span class="line">                manifest.srcFile  <span class="string">&#x27;src/main/module/AndroidManifest.xml&#x27;</span></span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                <span class="comment">// 不是组件，合并到宿主apk中，读取默认的xml</span></span><br><span class="line">                manifest.srcFile  <span class="string">&#x27;src/main/AndroidManifest.xml&#x27;</span></span><br><span class="line">                java &#123;</span><br><span class="line">                    exclude <span class="string">&#x27;debug/**&#x27;</span></span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        main &#123;</span><br><span class="line">            jniLibs.srcDirs = [<span class="string">&#x27;libs&#x27;</span>]</span><br><span class="line">            <span class="keyword">if</span> (isComponent.toBoolean()) &#123;</span><br><span class="line">                <span class="comment">// 是组件，独立打包apk，读取特定的xml</span></span><br><span class="line">                manifest.srcFile  <span class="string">&#x27;src/main/module/AndroidManifest.xml&#x27;</span></span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                <span class="comment">// 不是组件，合并到宿主apk中，读取默认的xml</span></span><br><span class="line">                manifest.srcFile  <span class="string">&#x27;src/main/AndroidManifest.xml&#x27;</span></span><br><span class="line">                java &#123;</span><br><span class="line">                    exclude <span class="string">&#x27;debug/**&#x27;</span></span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    buildTypes &#123;</span><br><span class="line">        debug &#123;</span><br><span class="line">            <span class="comment">/**</span></span><br><span class="line"><span class="comment">             * 根据构建类型 设置应用ID；如果您希望同一设备上同时具有调试版本和发布版本，这会很有用，因为两个 APK 不能具有相同的应用 ID。</span></span><br><span class="line"><span class="comment">             */</span></span><br><span class="line">            applicationIdSuffix <span class="string">&quot;.debug&quot;</span></span><br><span class="line">            minifyEnabled <span class="literal">false</span></span><br><span class="line">            proguardFiles getDefaultProguardFile(<span class="string">&#x27;proguard-android.txt&#x27;</span>), <span class="string">&#x27;proguard-rules.pro&#x27;</span></span><br><span class="line">        &#125;</span><br><span class="line">        release &#123;</span><br><span class="line">            minifyEnabled <span class="literal">false</span></span><br><span class="line">            proguardFiles getDefaultProguardFile(<span class="string">&#x27;proguard-android.txt&#x27;</span>), <span class="string">&#x27;proguard-rules.pro&#x27;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    dataBinding &#123;</span><br><span class="line">        enabled <span class="literal">true</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></div>
<h3 id="settinggradle"><a href="#setting-gradle" class="headerlink" title="setting.gradle"></a>setting.gradle<a href="#settinggradle" class="header-anchor">#</a></h3><div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="GROOVY"><figure class="iseeu highlight /groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">include <span class="string">&#x27;:lib-common-ui&#x27;</span></span><br><span class="line">include <span class="string">&#x27;:app-vip&#x27;</span></span><br><span class="line">include <span class="string">&#x27;:module-news&#x27;</span></span><br><span class="line">include <span class="string">&#x27;:module-live&#x27;</span></span><br><span class="line">include <span class="string">&#x27;:module-shop&#x27;</span></span><br><span class="line">include <span class="string">&#x27;:app-normal&#x27;</span></span><br><span class="line">rootProject.name = <span class="string">&quot;haier-common-app&quot;</span></span><br></pre></td></tr></table></figure></div>
<h2 id="module-news"><a href="#module-news" class="headerlink" title="module-news"></a>module-news<a href="#module-news" class="header-anchor">#</a></h2><blockquote>
<p>news\shop\live同理</p>
</blockquote>
<h3 id="buildgradle"><a href="#build-gradle-1" class="headerlink" title="build.gradle"></a>build.gradle<a href="#buildgradle" class="header-anchor">#</a></h3><div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="GROOVY"><figure class="iseeu highlight /groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">apply <span class="attr">from:</span> <span class="string">&quot;../module.build.gradle&quot;</span></span><br><span class="line">android &#123;</span><br><span class="line">    defaultConfig &#123;</span><br><span class="line">        <span class="comment">/**</span></span><br><span class="line"><span class="comment">         * 如果是组件，则使用当前组件的包名,不是组件，则无需包名</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line">        <span class="keyword">if</span> (isComponent.toBoolean()) &#123;</span><br><span class="line">            applicationId <span class="string">&quot;com.haier.news&quot;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">dependencies &#123;</span><br><span class="line">    implementation fileTree(<span class="attr">include:</span> [<span class="string">&#x27;*.jar&#x27;</span>], <span class="attr">dir:</span> <span class="string">&#x27;libs&#x27;</span>)</span><br><span class="line">    api rootProject.ext.support[<span class="string">&quot;design&quot;</span>]</span><br><span class="line">    api rootProject.ext.support[<span class="string">&quot;support-v4&quot;</span>]</span><br><span class="line">    api rootProject.ext.support[<span class="string">&quot;appcompat-v7&quot;</span>]</span><br><span class="line">    api rootProject.ext.support[<span class="string">&quot;recyclerview-v7&quot;</span>]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></div>
<p><img src="http://cdn.yangchaofan.cn/typora/image-20210608182147783.png" alt="image-20210608182147783"></p>
<h3 id="moduleandroidmanifestxml"><a href="#module-AndroidManifest-xml" class="headerlink" title="module/AndroidManifest.xml"></a>module/AndroidManifest.xml<a href="#moduleandroidmanifestxml" class="header-anchor">#</a></h3><div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="XML"><figure class="iseeu highlight /xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">manifest</span> <span class="attr">xmlns:android</span>=<span class="string">&quot;http://schemas.android.com/apk/res/android&quot;</span></span></span><br><span class="line"><span class="tag">    <span class="attr">package</span>=<span class="string">&quot;com.haier.news&quot;</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    &lt;application</span><br><span class="line">        android:allowBackup=&quot;true&quot;</span><br><span class="line">        android:icon=&quot;@mipmap/ic_launcher&quot;</span><br><span class="line">        android:label=&quot;@string/app_name&quot;</span><br><span class="line">        android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;</span><br><span class="line">        android:supportsRtl=&quot;true&quot;</span><br><span class="line">        android:theme=&quot;@style/Theme.Haiercommonapp&quot;&gt;</span><br><span class="line">        <span class="tag">&lt;<span class="name">activity</span> <span class="attr">android:name</span>=<span class="string">&quot;.FeedNewsHomeActivity&quot;</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">intent-filter</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">action</span> <span class="attr">android:name</span>=<span class="string">&quot;android.intent.action.MAIN&quot;</span> /&gt;</span></span><br><span class="line"></span><br><span class="line">                <span class="tag">&lt;<span class="name">category</span> <span class="attr">android:name</span>=<span class="string">&quot;android.intent.category.LAUNCHER&quot;</span> /&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">intent-filter</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">activity</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">application</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">manifest</span>&gt;</span></span><br></pre></td></tr></table></figure></div>
<h3 id="androidmanifestxml"><a href="#AndroidManifest-xml" class="headerlink" title="AndroidManifest.xml"></a>AndroidManifest.xml<a href="#androidmanifestxml" class="header-anchor">#</a></h3><div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="XML"><figure class="iseeu highlight /xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">manifest</span> <span class="attr">xmlns:android</span>=<span class="string">&quot;http://schemas.android.com/apk/res/android&quot;</span></span></span><br><span class="line"><span class="tag">    <span class="attr">package</span>=<span class="string">&quot;com.haier.news&quot;</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    &lt;application</span><br><span class="line">        android:allowBackup=&quot;true&quot;</span><br><span class="line">        android:icon=&quot;@mipmap/ic_launcher&quot;</span><br><span class="line">        android:label=&quot;@string/app_name&quot;</span><br><span class="line">        android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;</span><br><span class="line">        android:supportsRtl=&quot;true&quot;</span><br><span class="line">        android:theme=&quot;@style/Theme.Haiercommonapp&quot;&gt;</span><br><span class="line">        <span class="tag">&lt;<span class="name">activity</span> <span class="attr">android:name</span>=<span class="string">&quot;.FeedNewsHomeActivity&quot;</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">activity</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">application</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">manifest</span>&gt;</span></span><br></pre></td></tr></table></figure></div>
<h2 id="lib-common-ui"><a href="#lib-common-ui" class="headerlink" title="lib-common-ui"></a>lib-common-ui<a href="#lib-common-ui" class="header-anchor">#</a></h2><p><img src="http://cdn.yangchaofan.cn/typora/image-20210608182703542.png" alt="image-20210608182703542"></p>
<h3 id="moduleandroidmanifestxml"><a href="#module-AndroidManifest-xml-1" class="headerlink" title="module/AndroidManifest.xml"></a>module/AndroidManifest.xml<a href="#moduleandroidmanifestxml" class="header-anchor">#</a></h3><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">&lt;?xml version=<span class="string">&quot;1.0&quot;</span> encoding=<span class="string">&quot;utf-8&quot;</span>?&gt;</span><br><span class="line">&lt;manifest xmlns:android=<span class="string">&quot;http://schemas.android.com/apk/res/android&quot;</span></span><br><span class="line">    package=<span class="string">&quot;com.haier.common.ui&quot;</span>&gt;</span><br><span class="line"></span><br><span class="line">    &lt;application</span><br><span class="line">        android:allowBackup=<span class="string">&quot;true&quot;</span></span><br><span class="line">        <span class="symbol">android:</span>icon=<span class="string">&quot;@mipmap/ic_launcher&quot;</span></span><br><span class="line">        <span class="symbol">android:</span>label=<span class="string">&quot;@string/app_name&quot;</span></span><br><span class="line">        <span class="symbol">android:</span>roundIcon=<span class="string">&quot;@mipmap/ic_launcher_round&quot;</span></span><br><span class="line">        <span class="symbol">android:</span>supportsRtl=<span class="string">&quot;true&quot;</span></span><br><span class="line">        <span class="symbol">android:</span>theme=<span class="string">&quot;@style/Theme.Haiercommonapp&quot;</span>&gt;</span><br><span class="line">        &lt;!--仅作为独立apk的时候，才运行Activity，作为测试common-ui的首页--&gt;</span><br><span class="line">        &lt;activity <span class="attr">android:</span>name=<span class="string">&quot;.CommonUiHomeActivity&quot;</span>&gt;</span><br><span class="line">            &lt;intent-filter&gt;</span><br><span class="line">                &lt;action <span class="attr">android:</span>name=<span class="string">&quot;android.intent.action.MAIN&quot;</span> /&gt;</span><br><span class="line"></span><br><span class="line">                &lt;category <span class="attr">android:</span>name=<span class="string">&quot;android.intent.category.LAUNCHER&quot;</span> /&gt;</span><br><span class="line">            &lt;/intent-filter&gt;</span><br><span class="line">        &lt;/activity&gt;</span><br><span class="line">    &lt;/application&gt;</span><br><span class="line"></span><br><span class="line">&lt;/manifest&gt;</span><br></pre></td></tr></table></figure>


<h3 id="androidmanifestxml"><a href="#AndroidManifest-xml-1" class="headerlink" title="AndroidManifest.xml"></a>AndroidManifest.xml<a href="#androidmanifestxml" class="header-anchor">#</a></h3><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">&lt;?xml version=<span class="string">&quot;1.0&quot;</span> encoding=<span class="string">&quot;utf-8&quot;</span>?&gt;</span><br><span class="line">&lt;manifest xmlns:android=<span class="string">&quot;http://schemas.android.com/apk/res/android&quot;</span></span><br><span class="line">    package=<span class="string">&quot;com.haier.common.ui&quot;</span>&gt;</span><br><span class="line"></span><br><span class="line">    &lt;application</span><br><span class="line">        android:allowBackup=<span class="string">&quot;true&quot;</span></span><br><span class="line">        <span class="symbol">android:</span>icon=<span class="string">&quot;@mipmap/ic_launcher&quot;</span></span><br><span class="line">        <span class="symbol">android:</span>label=<span class="string">&quot;@string/app_name&quot;</span></span><br><span class="line">        <span class="symbol">android:</span>roundIcon=<span class="string">&quot;@mipmap/ic_launcher_round&quot;</span></span><br><span class="line">        <span class="symbol">android:</span>supportsRtl=<span class="string">&quot;true&quot;</span></span><br><span class="line">        <span class="symbol">android:</span>theme=<span class="string">&quot;@style/Theme.Haiercommonapp&quot;</span>&gt;</span><br><span class="line">    &lt;/application&gt;</span><br><span class="line"></span><br><span class="line">&lt;/manifest&gt;</span><br></pre></td></tr></table></figure>
<h3 id="buildgradle"><a href="#build-gradle-2" class="headerlink" title="build.gradle"></a>build.gradle<a href="#buildgradle" class="header-anchor">#</a></h3><div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="GROOVY"><figure class="iseeu highlight /groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">apply <span class="attr">from:</span> <span class="string">&quot;../module.build.gradle&quot;</span></span><br><span class="line">android &#123;</span><br><span class="line">    defaultConfig &#123;</span><br><span class="line">        <span class="comment">/**</span></span><br><span class="line"><span class="comment">         * 如果是组件，则使用当前组件的包名,不是组件，则无需包名</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line">        <span class="keyword">if</span> (isComponent.toBoolean()) &#123;</span><br><span class="line">            applicationId <span class="string">&quot;com.haier.common.ui&quot;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">dependencies &#123;</span><br><span class="line">    implementation fileTree(<span class="attr">include:</span> [<span class="string">&#x27;*.jar&#x27;</span>], <span class="attr">dir:</span> <span class="string">&#x27;libs&#x27;</span>)</span><br><span class="line">    api rootProject.ext.support[<span class="string">&quot;design&quot;</span>]</span><br><span class="line">    api rootProject.ext.support[<span class="string">&quot;support-v4&quot;</span>]</span><br><span class="line">    api rootProject.ext.support[<span class="string">&quot;appcompat-v7&quot;</span>]</span><br><span class="line">    api rootProject.ext.support[<span class="string">&quot;recyclerview-v7&quot;</span>]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></div>
<h2 id="app-vip"><a href="#app-vip" class="headerlink" title="app-vip"></a>app-vip<a href="#app-vip" class="header-anchor">#</a></h2><p><img src="http://cdn.yangchaofan.cn/typora/image-20210608182315991.png" alt="image-20210608182315991"></p>
<h3 id="androidmanifestxml"><a href="#AndroidManifest-xml-2" class="headerlink" title="AndroidManifest.xml"></a>AndroidManifest.xml<a href="#androidmanifestxml" class="header-anchor">#</a></h3><div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="XML"><figure class="iseeu highlight /xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">manifest</span> <span class="attr">xmlns:android</span>=<span class="string">&quot;http://schemas.android.com/apk/res/android&quot;</span></span></span><br><span class="line"><span class="tag">    <span class="attr">package</span>=<span class="string">&quot;com.haier.app.vip&quot;</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    &lt;application</span><br><span class="line">        android:allowBackup=&quot;true&quot;</span><br><span class="line">        android:icon=&quot;@mipmap/ic_launcher&quot;</span><br><span class="line">        android:label=&quot;@string/app_name&quot;</span><br><span class="line">        android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;</span><br><span class="line">        android:supportsRtl=&quot;true&quot;</span><br><span class="line">        android:theme=&quot;@style/Theme.Haiercommonapp&quot;&gt;</span><br><span class="line">    <span class="tag">&lt;/<span class="name">application</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">manifest</span>&gt;</span></span><br></pre></td></tr></table></figure></div>
<h3 id="buildgradle"><a href="#build-gradle-3" class="headerlink" title="build.gradle"></a>build.gradle<a href="#buildgradle" class="header-anchor">#</a></h3><div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="GROOVY"><figure class="iseeu highlight /groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line">plugins &#123;</span><br><span class="line">    id <span class="string">&#x27;com.android.application&#x27;</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">android &#123;</span><br><span class="line">    compileSdkVersion rootProject.ext.androidinfo.compileSdkVersion</span><br><span class="line"></span><br><span class="line">    defaultConfig &#123;</span><br><span class="line">        applicationId <span class="string">&quot;com.haier.tft&quot;</span></span><br><span class="line">        minSdkVersion rootProject.ext.androidinfo.minSdkVersion</span><br><span class="line">        targetSdkVersion rootProject.ext.androidinfo.targetSdkVersion</span><br><span class="line">        versionCode rootProject.ext.androidinfo.versionCode</span><br><span class="line">        versionName rootProject.ext.androidinfo.versionName</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    buildTypes &#123;</span><br><span class="line">        release &#123;</span><br><span class="line">            minifyEnabled <span class="literal">false</span></span><br><span class="line">            proguardFiles getDefaultProguardFile(<span class="string">&#x27;proguard-android-optimize.txt&#x27;</span>), <span class="string">&#x27;proguard-rules.pro&#x27;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    compileOptions &#123;</span><br><span class="line">        sourceCompatibility JavaVersion.VERSION_1_8</span><br><span class="line">        targetCompatibility JavaVersion.VERSION_1_8</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">dependencies &#123;</span><br><span class="line">    <span class="keyword">if</span> (!isComponent.toBoolean()) &#123;</span><br><span class="line">        <span class="comment">// 新增组件，如果属于app-apk，则引入到这里，将组件以lib形式打包成app-apk</span></span><br><span class="line">        <span class="comment">// 新增组件，如果不属于app-apk，则不需要引入到这里，即app-apk只引入自己需要的组件</span></span><br><span class="line">        implementation project(<span class="string">&#x27;:module-live&#x27;</span>)</span><br><span class="line">        implementation project(<span class="string">&#x27;:module-shop&#x27;</span>)</span><br><span class="line">        implementation project(<span class="string">&#x27;:module-news&#x27;</span>)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></div>
<h2 id="app-normal"><a href="#app-normal" class="headerlink" title="app-normal"></a>app-normal<a href="#app-normal" class="header-anchor">#</a></h2><p><img src="http://cdn.yangchaofan.cn/typora/image-20210608182509726.png" alt="image-20210608182509726"></p>
<h3 id="androidmanifestxml"><a href="#AndroidManifest-xml-3" class="headerlink" title="AndroidManifest.xml"></a>AndroidManifest.xml<a href="#androidmanifestxml" class="header-anchor">#</a></h3><div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="XML"><figure class="iseeu highlight /xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">manifest</span> <span class="attr">xmlns:android</span>=<span class="string">&quot;http://schemas.android.com/apk/res/android&quot;</span></span></span><br><span class="line"><span class="tag">    <span class="attr">package</span>=<span class="string">&quot;com.haier.tft&quot;</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">&lt;!--宿主app，空壳，仅用于合并清单文件、组件资源、library资源--&gt;</span></span><br><span class="line">    &lt;application</span><br><span class="line">        android:allowBackup=&quot;true&quot;</span><br><span class="line">        android:icon=&quot;@mipmap/ic_launcher&quot;</span><br><span class="line">        android:label=&quot;@string/app_name&quot;</span><br><span class="line">        android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;</span><br><span class="line">        android:supportsRtl=&quot;true&quot;</span><br><span class="line">        android:theme=&quot;@style/Theme.Haiercommonapp&quot; /&gt;</span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">manifest</span>&gt;</span></span><br></pre></td></tr></table></figure></div>
<h3 id="buildgradle"><a href="#build-gradle-4" class="headerlink" title="build.gradle"></a>build.gradle<a href="#buildgradle" class="header-anchor">#</a></h3><div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="GROOVY"><figure class="iseeu highlight /groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line">plugins &#123;</span><br><span class="line">    id <span class="string">&#x27;com.android.application&#x27;</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">android &#123;</span><br><span class="line">    compileSdkVersion rootProject.ext.androidinfo.compileSdkVersion</span><br><span class="line"></span><br><span class="line">    defaultConfig &#123;</span><br><span class="line">        applicationId <span class="string">&quot;com.haier.tft&quot;</span></span><br><span class="line">        minSdkVersion rootProject.ext.androidinfo.minSdkVersion</span><br><span class="line">        targetSdkVersion rootProject.ext.androidinfo.targetSdkVersion</span><br><span class="line">        versionCode rootProject.ext.androidinfo.versionCode</span><br><span class="line">        versionName rootProject.ext.androidinfo.versionName</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    buildTypes &#123;</span><br><span class="line">        release &#123;</span><br><span class="line">            minifyEnabled <span class="literal">false</span></span><br><span class="line">            proguardFiles getDefaultProguardFile(<span class="string">&#x27;proguard-android-optimize.txt&#x27;</span>), <span class="string">&#x27;proguard-rules.pro&#x27;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    compileOptions &#123;</span><br><span class="line">        sourceCompatibility JavaVersion.VERSION_1_8</span><br><span class="line">        targetCompatibility JavaVersion.VERSION_1_8</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">dependencies &#123;</span><br><span class="line">    <span class="keyword">if</span> (!isComponent.toBoolean()) &#123;</span><br><span class="line">        implementation project(<span class="string">&#x27;:module-shop&#x27;</span>)</span><br><span class="line">        implementation project(<span class="string">&#x27;:module-live&#x27;</span>)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></div>
<h2 id="实践总结"><a href="#实践总结" class="headerlink" title="实践总结"></a><strong>实践总结</strong><a href="#实践总结" class="header-anchor">#</a></h2><table>
<thead>
<tr>
<th></th>
<th>根目录</th>
<th>module目录</th>
<th>lib目录</th>
</tr>
</thead>
<tbody><tr>
<td>build.gradle</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>AndroidManifest.xml</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>module.build.gradle</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>gradle.properties</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>config.gradle</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>settings.gradle</td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody></table>
<h1 id="组件化注意事项"><a href="#组件化注意事项" class="headerlink" title="组件化注意事项"></a>组件化注意事项<a href="#组件化注意事项" class="header-anchor">#</a></h1><ul>
<li>分别处理独立运行的情况、合并的情况</li>
<li>在模块中引用根目录的<code>config.gradle</code>，需要在根目录的<code>build.gradle</code>通过<code>apply</code>导入才可以，否则会报错，找不到<code>config.gradle</code>中的属性</li>
<li><code>module.build.gradle</code>中定义了<code>defaultConfig</code>,在<code>module</code>模块中的<code>build.gradle</code>也写了<code>defaultConfig</code>，然后通过apply导入了<code>module.build.gradle</code>，两个<code>build.gradle</code>的<code>defaultCOnfig</code>中的内容会如何处理？<ul>
<li>答：目前看上去是合并了如果值不冲突，则合并成一份；如果值冲突，则不清楚谁先谁后</li>
</ul>
</li>
<li>编写<code>sourceSets</code>的语法，对于<code>jnilibs</code>和<code>srcfile</code>赋值方式有所差异，一个带等号，一个不带等号<ul>
<li><code>jniLibs.srcDirs=[&#39;libs&#39;]</code></li>
<li> <code>manifest.srcFile &#39;src/main/module/AndroidManifest.xml&#39;</code></li>
</ul>
</li>
</ul>
<h1 id="组件化技术选型"><a href="#组件化技术选型" class="headerlink" title="组件化技术选型"></a>组件化技术选型<a href="#组件化技术选型" class="header-anchor">#</a></h1><p>组件化技术实现了在Debug调试阶段，每个功能模块可以独立变成APP调试，但在打包编译阶段，其最终还是将所有模块打包成一个APK。</p>
<blockquote>
<p><strong>插件化</strong>：也叫动态加载技术，分宿主APK和插件APK，宿主APK可以理解为就是安装到手机的主APK（诸如手机淘宝），各个功能模块抽取变成插件APK（诸如饿了么，淘票票），这些插件APK可以随着宿主APK一起编译打包安装到手机上，也可以变成远程APK放在服务器，按需下载安装，实现功能的动态配置。从广义上理解，可以把Android系统当成一个宿主APK，各个安装到手机上的软件当成插件APK，从而组成一个插件化系统。<br><strong>组件化</strong>：组件化技术实现了在Debug调试阶段，每个功能模块可以独立变成APP调试，但在打包编译阶段，其最终还是将所有模块打包成一个APK。<br><strong>热修复</strong>：热修复技术有助于我们在用户无感知的时候修复APK，悄无声息的将Bug修复掉，我们希望热修复它是不新增资源文件，四大组件等操作，只是单纯的解决代码逻辑上的Bug，可以简单理解插件化技术是热修复的高级版</p>
</blockquote>
<p>下表格摘自<a target="_blank" rel="noopener" href="https://github.com/luckybilly/AndroidComponentizeLibs"> 多个维度对比一些有代表性的开源android组件化开发方案</a></p>
<table>
<thead>
<tr>
<th>对比项</th>
<th><a target="_blank" rel="noopener" href="https://github.com/luckybilly/CC">CC</a></th>
<th><a target="_blank" rel="noopener" href="https://github.com/luojilab/DDComponentForAndroid">得到DDComponentForAndroid</a></th>
<th><a target="_blank" rel="noopener" href="https://github.com/SpinyTech/ModularizationArchitecture">ModularizationArchitecture</a></th>
<th><a target="_blank" rel="noopener" href="https://github.com/alibaba/Arouter">阿里Arouter</a><br>(网上很多组件化方案的路由引擎，如<a target="_blank" rel="noopener" href="https://github.com/guiying712/AndroidModulePattern">AndroidModulePattern</a>)</th>
<th>聚美组件化方案<br>（基于<a target="_blank" rel="noopener" href="https://github.com/JumeiRdGroup/Router">聚美Router</a>）</th>
<th><a target="_blank" rel="noopener" href="https://github.com/mzule/ActivityRouter">ActivityRouter</a></th>
</tr>
</thead>
<tbody><tr>
<td>开源时间</td>
<td>2017-11</td>
<td>2017-9</td>
<td>2017-1</td>
<td>2016-12</td>
<td>2016-9</td>
<td>2016-4</td>
</tr>
<tr>
<td>介绍文章</td>
<td><a target="_blank" rel="noopener" href="https://github.com/luckybilly/CC/wiki">wiki</a></td>
<td><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/1b1d77f58e84">Android彻底组件化方案实践</a></td>
<td><a target="_blank" rel="noopener" href="http://blog.spinytech.com/2016/12/28/android_modularization/">Android架构思考(模块化、多进程)</a></td>
<td><a target="_blank" rel="noopener" href="https://yq.aliyun.com/articles/71687?spm=5176.100240.searchblog.7.8os9Go">开源最佳实践：Android平台页面路由框架Arouter</a></td>
<td><a target="_blank" rel="noopener" href="https://juejin.im/post/5a4b4425518825128654eef4">聚美组件化实践之路</a></td>
<td><a target="_blank" rel="noopener" href="https://joyrun.github.io/2016/08/01/ActivityRouter/">ActivityRouter路由框架：通过注解实现URL打开Activity</a></td>
</tr>
<tr>
<td>通信机制</td>
<td>组件总线</td>
<td>路由 + 接口下沉</td>
<td>组件总线</td>
<td>路由 + 接口下沉</td>
<td>路由 + 接口下沉</td>
<td>路由 + 静态方法</td>
</tr>
<tr>
<td>activity跳转</td>
<td>✅</td>
<td>✅</td>
<td>✅</td>
<td>✅</td>
<td>✅</td>
<td>✅</td>
</tr>
<tr>
<td>是否支持降级处理</td>
<td>✅</td>
<td>❌</td>
<td>✅</td>
<td>✅</td>
<td>✅</td>
<td>✅</td>
</tr>
<tr>
<td>activity变量自动注入</td>
<td>❌</td>
<td>1. 通过apt生成自动注入代码<br>2. 在onCreate中调用<code>AutowiredService.Factory.getInstance().create().autowire(this);</code>或者继承BaseActivity</td>
<td>❌</td>
<td>1. 通过apt生成解析参数的代码<br>2. 在onCreate方法中调用<code>ARouter.getInstance().inject(this);</code>实现自动注入</td>
<td>❌</td>
<td>❌</td>
</tr>
<tr>
<td>startActivityForResult</td>
<td>支持Activity/Fragment,但不建议使用<br>建议使用统一的组件调用方式</td>
<td>仅支持Activity</td>
<td>仅支持Activity</td>
<td>仅支持Activity</td>
<td>支持Activity/Fragment</td>
<td>仅支持Activity</td>
</tr>
<tr>
<td>调用方式(页面跳转)</td>
<td>同步直接返回结果或异步回调结果:<br><code>CCResult result = CC.obtainBuilder(&quot;ComponentA&quot;).build().call();</code><br>或<br><code>String callId = CC.obtainBuilder(&quot;ComponentA&quot;).build().callAsync(new IComponentCallback()&#123;...&#125;);</code></td>
<td>onActivityResult返回结果:<br><code>UIRouter.getInstance().openUri(getActivity(), url, bundle);</code></td>
<td>RouterResponse response = LocalRouter.getInstance(MaApplication.getMaApplication())<br>.route(MainActivity.this, RouterRequest.obtain(MainActivity.this)<br>            .domain(“com.spinytech.maindemo:music”)<br>            .provider(“music”)<br>            .action(“shutdown”));<br>String temp = response.getData();</td>
<td>onActivityResult返回结果:<br><code>ARouter.getInstance().build(&quot;/test/activity&quot;).navigation();</code></td>
<td>onActivityResult返回结果:<br><code>Router.create(url).open(context);</code></td>
<td>onActivityResult返回结果:<br><code>Routers.open(context, url);</code></td>
</tr>
<tr>
<td>调用方式(调用服务)</td>
<td>与页面跳转相同</td>
<td><code>Router.getInstance().getService(ReadBookService.class.getSimpleName())</code></td>
<td>与页面跳转相同</td>
<td><code>ARouter.getInstance().navigation(HelloService.class).sayHello();</code></td>
<td><code>PipeManager.get(LoginPipe.class).logout();</code></td>
<td>与页面跳转相同</td>
</tr>
<tr>
<td>组件向外提供服务</td>
<td>与页面跳转一致，在IComponent中实现</td>
<td>接口下沉到base中，组件中实现接口并在IApplicationLike中添加代码注册到Router中</td>
<td>与页面跳转一致，实现一个对应的Action并在其所属的Provider中注册即可</td>
<td>接口继承IProvider并下沉到base中，组件中实现接口并通过注解来暴露服务</td>
<td>接口下沉到base中，组件中实现接口并在ApplicationDelegate中向接口管理类注册<code>PipeManager.register(CorePipe.class, new CorePipeImpl());</code></td>
<td>在静态方法上加注解来暴露服务，但不支持返回值，且参数固定位(context, bundle)</td>
</tr>
<tr>
<td>Fragment组件化支持</td>
<td>在IComponent中实现，并支持后续Fragment内部功能调用</td>
<td>调用服务的方式实现，未支持后续Fragment内部的功能调用</td>
<td>不支持</td>
<td>调用服务的方式实现，未支持后续Fragment内部的功能调用</td>
<td>调用服务的方式实现，未支持后续Fragment内部的功能调用</td>
<td>不支持</td>
</tr>
<tr>
<td>组件自动注册方案</td>
<td>TrasnformAPI + ASM扫描组件类(IComponent接口实现类)并注册到ComponentMananger中，无需手动维护组件列表</td>
<td>apt生成各module的路由表<br>TrasnformAPI + javassist将IApplicationLike的注册代码生成到自定义application.onCreate方法中，无需手动维护组件列表</td>
<td>未实现自动注册，<br>1. Action列表在其所属的Provider中注册<br>2. Provider在其所属的ApplicationLogic中注册<br>3. ApplicationLogic在主app的Application中注册</td>
<td>新版本(1.3.0)开始支持通过插件完成路由注册<br>1. apt生成各module的路由表<br>2. TrasnformAPI + ASM扫描路由表并注册到LogisticsCenter中，无需手动维护组件列表</td>
<td>1. apt生成各module的路由表pkg.RouterRuleCreator类<br>2. 在ComponentPackages中定义所有RouterRuleCreator的包名<br>3.在BaseApplication中反射所有的包名找到所有路由表RouterRuleCreator<br>4. 需要手动维护ComponentPackages类中的包名列表</td>
<td>1. apt生成各module的路由表<br>2. apt在application的module通过Modules注解生成RouterInit进行注册<br>3. 需要手动维护Modules注解中的组件列表</td>
</tr>
<tr>
<td>组件单独运行的方式</td>
<td>切换library/application方式编译，提供2种方式：<br>1. module/build.gradle中切换<code>ext.runAsApp=trueOrFalse</code><br>2. 在local.properties中切换<code>moduleName=trueOrFalse</code>（推荐使用的方式，不会提交到代码仓库中）</td>
<td>切换library/application方式编译，在module/gradle.properties中切换<code>isRunAlone=trueOrFalse</code></td>
<td>切换library/application方式编译，框架本身没有提供切换方式，开发者自行解决</td>
<td>切换library/application方式编译，框架本身没有提供切换方式，开发者自行解决</td>
<td>组件module始终以library方式编译，额外提供app壳子，可以按需将多个组件依赖进来一起打包。<br>好处是所有组件调试时包名相同，能满足分享及地图等第三方SDK对包名的要求</td>
<td>切换library/application方式编译，框架本身没有提供切换方式，开发者自行解决</td>
</tr>
<tr>
<td>跨app组件调用支持</td>
<td>✅</td>
<td>❌</td>
<td>✅</td>
<td>❌</td>
<td>❌</td>
<td>✅</td>
</tr>
<tr>
<td>跨app调用开关及权限设置</td>
<td>✅</td>
<td>/</td>
<td>❌</td>
<td>/</td>
<td>/</td>
<td>❌</td>
</tr>
<tr>
<td>组件app运行时调用其它组件</td>
<td>组件同时安装在设备上即可，实际开发中一般是当前正在开发的组件和主app中的组件互相调用.<br>通过广播 + Service + LocalSocket实现，没有UrlScheme调用时弹出的选择框</td>
<td>将需要调用的组件一起打包才能调用</td>
<td>组件同时安装在设备上即可，实际开发中一般是当前正在开发的组件和主app中的组件互相调用.<br>通过AIDL实现</td>
<td>一起打包或者通过urlScheme来统一转发</td>
<td>将需要调用的组件一起打包才能调用</td>
<td>UrlScheme原生支持跨app调用,组件同时安装在设备上即可<br>通过中介Activity转发:RouterActivity</td>
</tr>
<tr>
<td>组件依赖隔离</td>
<td>无需依赖、完全隔离</td>
<td>通过插件实现只在打apk包时才添加依赖，编码期间不能直接调用其它组件的代码，想知道如何实现可以戳<a target="_blank" rel="noopener" href="https://github.com/luojilab/DDComponentForAndroid/blob/master/build-gradle/src/main/groovy/com.dd.buildgradle/ComBuild.groovy#L118:18">这里</a></td>
<td>无需依赖、完全隔离</td>
<td>未隔离</td>
<td>未隔离</td>
<td>无需依赖、完全隔离</td>
</tr>
<tr>
<td>AOP支持</td>
<td>拦截器 + 组件内部Action进行AOP</td>
<td>❌</td>
<td>组件内部Action进行AOP</td>
<td>拦截器AOP</td>
<td>❌</td>
<td>❌</td>
</tr>
<tr>
<td>拦截器</td>
<td>✅</td>
<td>❌</td>
<td>❌</td>
<td>✅</td>
<td>✅</td>
<td>❌</td>
</tr>
<tr>
<td>组件调用的超时设置</td>
<td>✅</td>
<td>❌</td>
<td>❌</td>
<td>❌</td>
<td>❌</td>
<td>❌</td>
</tr>
<tr>
<td>组件调用的取消</td>
<td>✅</td>
<td>❌</td>
<td>❌</td>
<td>❌</td>
<td>❌</td>
<td>❌</td>
</tr>
<tr>
<td>动态注册/注销组件</td>
<td>✅</td>
<td>✅</td>
<td>❌</td>
<td>❌</td>
<td>❌</td>
<td>❌</td>
</tr>
<tr>
<td>特点</td>
<td>1. 可以跨app调用，初期改造时即可单独编译组件运行<br>2. 提供统一的组件调用及实现方式（不管是否跨app调用、页面跳转、服务调用、同步/异步调用）<br>3. 组件自动注册，无需维护<br>4. 提供了ActionProcessor按需加载的支持</td>
<td>1. 编码期间组件依赖通过插件进行隔离，避免直接调用其它组件的代码<br>2. 提供了兼容ARouter的方案<br>3. 组件自动注册，无需维护</td>
<td>1. 可以跨app、app内跨进程调用<br>2. 组件运行在各自进程中，单独运行与联合打包切换时需要修改进程名称<br>3. 组件需指定同步实现还是异步实现，调用组件时统一拿到RouterResponse作为返回值，可以自行决定同步还是异步方式调用RouterResponse.getData()来获取结果，但异步获取时需要自己维护线程</td>
<td>1. 阿里出品，使用者众多，QQ群里交流比较活跃<br>2. 支持分级按需加载 <br>3. 是一个路由框架，并不是完整的组件化方案，可作为组件化架构的通信引擎</td>
<td>组件module可以始终以library方式编译，由统一的app壳子来安装调试，不需要切换library/application编译方式、避免了第三方SDK需要指定包名的问题、自定义权限重复导致安装冲突的问题、误操作导致apk upload到maven仓库的问题等</td>
<td>1. 业内最早的组件化支持库<br>2. 通过注解静态方法的方式暴露服务</td>
</tr>
<tr>
<td>组件定义代码侵入性</td>
<td>新增IComponent接口的实现类来定义组件，侵入性低</td>
<td>注解定义路由及参数自动注入，侵入性高</td>
<td>新增接口实现类，侵入性低</td>
<td>注解定义路由及参数自动注入，侵入性高</td>
<td>注解定义路由，侵入性高</td>
<td>注解定义路由，侵入性高</td>
</tr>
<tr>
<td>组件调用代码侵入性</td>
<td>高</td>
<td>高</td>
<td>高</td>
<td>高</td>
<td>高</td>
<td>高</td>
</tr>
<tr>
<td>混淆配置</td>
<td>无</td>
<td>所有下沉接口、框架中相关接口的实现类等</td>
<td><code>-dontwarn com.spinytech.**</code></td>
<td>框架中的所有类及框架相关接口的实现类</td>
<td>所有RouterRuleCreator类</td>
<td>框架中的所有类</td>
</tr>
<tr>
<td>老项目改造成本评估</td>
<td>低</td>
<td>一般</td>
<td>高</td>
<td>一般</td>
<td>高</td>
<td>低</td>
</tr>
<tr>
<td>方案使用的学习成本评估</td>
<td>低</td>
<td>一般</td>
<td>高</td>
<td>一般</td>
<td>一般</td>
<td>一般</td>
</tr>
<tr>
<td>后续维护成本评估</td>
<td>低</td>
<td>一般</td>
<td>高</td>
<td>低</td>
<td>一般</td>
<td>一般</td>
</tr>
<tr>
<td>QQ群</td>
<td>686844583</td>
<td>693097923</td>
<td>无</td>
<td>592278657 / 336755078</td>
<td>108895031</td>
<td>无</td>
</tr>
</tbody></table>
<blockquote>
<p>其他理论型组件化技术</p>
</blockquote>
<p>对</p>
<table>
<thead>
<tr>
<th>对比项</th>
<th><a target="_blank" rel="noopener" href="https://github.com/JessYanCoding/ArmsComponent"><strong>ArmsComponent</strong></a></th>
<th><a target="_blank" rel="noopener" href="https://github.com/mqzhangw/JIMU"><strong>JIMU</strong></a></th>
</tr>
</thead>
<tbody><tr>
<td>开源时间</td>
<td>2018年</td>
<td>2018年</td>
</tr>
<tr>
<td>相关文章</td>
<td><a target="_blank" rel="noopener" href="https://github.com/JessYanCoding/ArmsComponent/wiki"><strong>Wiki Documents (开发前必看!!!)</strong></a><br> <a target="_blank" rel="noopener" href="https://www.jianshu.com/p/f671dd76868f">文章介绍</a><br>辅助代码模板： <strong><a target="_blank" rel="noopener" href="https://github.com/JessYanCoding/ArmsComponent-Template">ArmsComponent-Template</a></strong></td>
<td><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/1b1d77f58e84">Android彻底组件化方案实践</a></td>
</tr>
<tr>
<td>架构图</td>
<td><img src="https://raw.githubusercontent.com/JessYanCoding/ArmsComponent/master/arts/ArmsComponentArchitecture.jpeg" alt="img"></td>
<td><img src="https://upload-images.jianshu.io/upload_images/6650461-92c8e8a0a078f6ef.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/563/format/webp" alt="img"></td>
</tr>
</tbody></table>
<h1 id="组件化参考文章"><a href="#组件化参考文章" class="headerlink" title="组件化参考文章"></a>组件化参考文章<a href="#组件化参考文章" class="header-anchor">#</a></h1><table>
<thead>
<tr>
<th>名称</th>
<th>大纲</th>
</tr>
</thead>
<tbody><tr>
<td><a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/25420181">安居客 Android 项目架构演进 - 知乎 (zhihu.com)</a></td>
<td></td>
</tr>
<tr>
<td><a target="_blank" rel="noopener" href="https://www.trinea.cn/android/didi-internationalization-android-evolution/">滴滴国际化项目 Android 端演进 (trinea.cn)</a></td>
<td></td>
</tr>
<tr>
<td><a target="_blank" rel="noopener" href="https://github.com/luckybilly/CC">CC: 业界首个支持渐进式组件化改造的Android组件化开源框架，支持跨进程调用</a></td>
<td>组件化改造的Android组件化开源框架<a target="_blank" rel="noopener" href="https://github.com/luckybilly/CC/wiki">wiki</a><br><a target="_blank" rel="noopener" href="https://github.com/luckybilly/CC/wiki/CC%E6%A1%86%E6%9E%B6%E5%AE%9E%E8%B7%B5(1)%EF%BC%9A%E5%AE%9E%E7%8E%B0%E7%99%BB%E5%BD%95%E6%88%90%E5%8A%9F%E5%86%8D%E8%BF%9B%E5%85%A5%E7%9B%AE%E6%A0%87%E7%95%8C%E9%9D%A2%E5%8A%9F%E8%83%BD">CC框架实践(1)：实现登录成功再进入目标界面功能</a><br><a target="_blank" rel="noopener" href="https://github.com/luckybilly/CC/wiki/CC%E6%A1%86%E6%9E%B6%E5%AE%9E%E8%B7%B5(2)%EF%BC%9AFragment%E5%92%8CView%E7%9A%84%E7%BB%84%E4%BB%B6%E5%8C%96">CC框架实践(2)：Fragment和View的组件化</a><br><a target="_blank" rel="noopener" href="https://github.com/luckybilly/CC/wiki/CC%E6%A1%86%E6%9E%B6%E5%AE%9E%E8%B7%B5(3):-%E8%AE%A9jsBridge%E6%9B%B4%E4%BC%98%E9%9B%85">CC框架实践(3): 让jsBridge更优雅</a></td>
</tr>
<tr>
<td><a target="_blank" rel="noopener" href="https://github.com/luojilab/DDComponentForAndroid">得到DDComponentForAndroid</a></td>
<td><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/1b1d77f58e84">Android彻底组件化方案实践</a><br>组件化设计思路 <a target="_blank" rel="noopener" href="https://mp.weixin.qq.com/s/RAOjrpie214w0byRndczmg">浅谈Android组件化</a><br>原理解释文章<a target="_blank" rel="noopener" href="http://www.jianshu.com/p/1b1d77f58e84">Android彻底组件化方案实践</a><br>demo解读文章<a target="_blank" rel="noopener" href="http://www.jianshu.com/p/59822a7b2fad">Android彻底组件化demo发布</a></td>
</tr>
<tr>
<td><a target="_blank" rel="noopener" href="https://github.com/SpinyTech/ModularizationArchitecture">ModularizationArchitecture</a></td>
<td><a target="_blank" rel="noopener" href="http://blog.spinytech.com/2016/12/28/android_modularization/">Android架构思考(模块化、多进程)</a><br><a target="_blank" rel="noopener" href="http://blog.spinytech.com/2017/02/01/ma_get_start_cn/">ModularizationArchitecture 使用教程</a></td>
</tr>
<tr>
<td><a target="_blank" rel="noopener" href="https://github.com/alibaba/ARouter">阿里ARouter</a></td>
<td><a target="_blank" rel="noopener" href="https://yq.aliyun.com/articles/71687?spm=5176.100240.searchblog.7.8os9Go">开源最佳实践：Android平台页面路由框架Arouter</a></td>
</tr>
<tr>
<td>聚美组件化方案<a target="_blank" rel="noopener" href="https://github.com/yjfnypeu/AndroidComponent">Demo</a><br>(基于<a target="_blank" rel="noopener" href="https://github.com/JumeiRdGroup/Router">聚美Router</a>)</td>
<td><a target="_blank" rel="noopener" href="https://juejin.im/post/5a4b4425518825128654eef4">聚美组件化实践之路</a><br><a target="_blank" rel="noopener" href="https://juejin.im/post/5a37771f6fb9a0450e7636e0">Router:一款单品、组件化、插件化全支持的路由框架</a></td>
</tr>
<tr>
<td><a target="_blank" rel="noopener" href="https://github.com/mzule/ActivityRouter">ActivityRouter</a></td>
<td><a target="_blank" rel="noopener" href="https://joyrun.github.io/2016/08/01/ActivityRouter/">ActivityRouter路由框架：通过注解实现URL打开Activity</a><br><a target="_blank" rel="noopener" href="https://mzule.github.io/2016/04/11/%E9%80%9A%E8%BF%87URL%E6%89%93%E5%BC%80Activity/">通过 URL 打开 Activity</a></td>
</tr>
<tr>
<td>美柚路由方案<a target="_blank" rel="noopener" href="https://github.com/gybin02/RouterKit">RouterKit</a></td>
<td>这个方案的特别之处在于其组件自动注册的方案：通过apt生成每个module的路由表，然后<a target="_blank" rel="noopener" href="https://github.com/gybin02/RouterKit/blob/master/app/build.gradle#L60:1">复制到app的assets目录</a>，运行的时候遍历asset目录，<a target="_blank" rel="noopener" href="https://github.com/gybin02/RouterKit/blob/master/jet_router/src/main/java/com/meiyou/router/Router.java#L322:17">反射对应的activity</a></td>
</tr>
<tr>
<td>组件总线方案<a target="_blank" rel="noopener" href="https://github.com/cangwang/ModuleBus">ModuleBus</a></td>
<td>组件化开发跨module交互方式—ModuleBus交互</td>
</tr>
</tbody></table>
<div id="footnotes"><hr><div id="footnotelist"><ol style="list-style: none; padding-left: 0; margin-left: 40px"><li id="fn:3"><span style="display: inline-block; vertical-align: top; padding-right: 10px; margin-left: -40px">3.</span><span style="display: inline-block; vertical-align: top; margin-left: 10px;"><a target="_blank" rel="noopener" href="https://developer.android.google.cn/studio/build?hl=zh_cn#sourcesets">配置构建  | Android 开发者  | Android Developers (google.cn)</a><a href="#fnref:3" rev="footnote"> ↩</a></span></li><li id="fn:4"><span style="display: inline-block; vertical-align: top; padding-right: 10px; margin-left: -40px">4.</span><span style="display: inline-block; vertical-align: top; margin-left: 10px;"><a target="_blank" rel="noopener" href="https://developer.android.google.cn/studio/build/manifest-merge?hl=zh_cn">合并多个清单文件  | Android 开发者  | Android Developers (google.cn)</a><a href="#fnref:4" rev="footnote"> ↩</a></span></li></ol></div></div><link rel="stylesheet" href="/css/bilicard.css" type="text/css">

        

      
    </div>

      <!-- 相关文章推荐 -->
     
          

  <div class="popular-posts-header">
    <i class="fa fa-graduation-cap"></i>
    相关文章
  </div>

 <details>
   <summary>点击查看</summary>
     <ul class="popular-posts">
     
       <li class="popular-posts-item">
         
         
         <div class="popular-posts-title"><a href="\blog\2021\01\android-structure-best-practice\" rel="bookmark">Android大厂架构设计最佳实践</a></div>
         
       </li>
     
       <li class="popular-posts-item">
         
         
         <div class="popular-posts-title"><a href="\blog\2021\01\Android-plug-in-technology-selection\" rel="bookmark">Android插件化技术选型</a></div>
         
       </li>
     
       <li class="popular-posts-item">
         
         
         <div class="popular-posts-title"><a href="\blog\2018\02\MVC-MVP-MVVM -of -architecture -selection\" rel="bookmark">架构选型之MVC、MVP、MVVM</a></div>
         
       </li>
     
       <li class="popular-posts-item">
         
         
         <div class="popular-posts-title"><a href="\blog\2016\04\Android-TOP-100-Program\" rel="bookmark">Android 百大框架排行榜</a></div>
         
       </li>
     
       <li class="popular-posts-item">
         
         
         <div class="popular-posts-title"><a href="\blog\2019\06\android-hotfix\" rel="bookmark">Android 热补丁技术详解大全</a></div>
         
       </li>
     
       <li class="popular-posts-item">
         
         
         <div class="popular-posts-title"><a href="\blog\2021\05\The-most-comprehensive-thinking-of-crash-practice-strategy\" rel="bookmark">Android Crash实践策略最全面思考</a></div>
         
       </li>
     
       <li class="popular-posts-item">
         
         
         <div class="popular-posts-title"><a href="\blog\2021\05\android-crash-who-kill-you\" rel="bookmark">Android Crash揭秘与实践</a></div>
         
       </li>
     
       <li class="popular-posts-item">
         
         
         <div class="popular-posts-title"><a href="\blog\2021\02\mtk-log\" rel="bookmark">mtk-log</a></div>
         
       </li>
     
       <li class="popular-posts-item">
         
         
         <div class="popular-posts-title"><a href="\blog\2021\02\android-bugfree-three-lines\" rel="bookmark">BugFree三剑客异常、日志、工具</a></div>
         
       </li>
     
       <li class="popular-posts-item">
         
         
         <div class="popular-posts-title"><a href="\blog\2021\02\Client-Skeleton-Screen\" rel="bookmark">Android骨架屏详解</a></div>
         
       </li>
     
     </ul>
 </details>



     

    
    
    

    <div>
          
            

          
    </div>

    

    <div>
      
        <div>
    
        <div class="read-over">-------------------本文结束 <i class="fa fa-paw"></i> 感谢您的阅读-------------------</div>
    
</div>

      
    </div>

    
      <div>
        <div class="share_reward">
  <div>坚持原创技术分享，感谢您的支持和鼓励！</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="http://cdn.yangchaofan.cn/BlogGifRes/20210313/s7mteFUqc8pH.png" alt=" 微信支付"/>
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="http://cdn.yangchaofan.cn/BlogGifRes/20210313/oQnokBcx6RUO.png" alt=" 支付宝"/>
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    
      <div>
        <ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者：</strong>
    叶金诚
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="http://idolcoder.gitee.io/blog/2021/01/Android-component-Practice-Guide/" title="Android组件化实践指南">http://idolcoder.gitee.io/blog/2021/01/Android-component-Practice-Guide/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>
    本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-nd/3.0/deed.zh" rel="external nofollow" target="_blank">Creative Commons BY-NC-ND 3.0</a> 许可协议。转载请注明出处！
  </li>
</ul>

      </div>
    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/blog/tags/Android/" rel="tag"> <i class="fa fa-tag"></i> Android</a>
          
            <a href="/blog/tags/%E5%BC%80%E6%BA%90%E6%A1%86%E6%9E%B6/" rel="tag"> <i class="fa fa-tag"></i> 开源框架</a>
          
            <a href="/blog/tags/%E6%8A%80%E6%9C%AF%E9%80%89%E5%9E%8B/" rel="tag"> <i class="fa fa-tag"></i> 技术选型</a>
          
        </div>
      

      
      
        <div class="post-widgets">
        

        

        
          
          <div id="needsharebutton-postbottom">
            <span class="btn">
              <i class="fa fa-share-alt" aria-hidden="true"></i>
            </span>
          </div>
        
        </div>
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2021/01/Android-plug-in-technology-selection/" rel="prev" title="Android插件化技术选型">
                <i class="fa fa-chevron-left"></i> Android插件化技术选型
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blog/2021/01/android-structure-best-practice/" rel="next" title="Android大厂架构设计最佳实践">
                Android大厂架构设计最佳实践 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
        
  <script>
    window._bd_share_config = {
      "common": {
        "bdText": "",
        "bdMini": "1",
        "bdMiniList": false,
        "bdPic": ""
      },
      "image": {
        "viewList": ["tsina", "douban", "sqq", "qzone", "weixin", "twi", "fbook"],
        "viewText": "分享到：",
        "viewSize": "16"
      },
      "slide": {
        "bdImg": "5",
        "bdPos": "left",
        "bdTop": "100"
      }
    }
  </script>

<script>
//  with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='//bdimg.share.baidu.com/static/api/js/share.js?cdnversion='+~(-new Date()/36e5)];
//    with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='/static/api/js/share.js?cdnversion='+~(-new Date()/36e5)];
</script>

      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
      <div id="lv-container" data-id="city" data-uid="MTAyMC81Mjc2OC8yOTI0NQ"></div>
    </div>

  





        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
      <div id="sidebar-dimmer"></div>
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <a href="/">
              <img class="site-author-image" itemprop="image"
                src="/blog/images/head.png"
                alt="" />
              </a>
            
              <p class="site-author-name" itemprop="name"></p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/blog/archives/">
              
                  <span class="site-state-item-count">24</span>
                  <span class="site-state-item-name">文章</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/blog/categories/index.html">
                  <span class="site-state-item-count">16</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/blog/tags/index.html">
                  <span class="site-state-item-count">14</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/blog/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
              <!-- 为Hexo Next主题添加哈林摇特效  -->
              <a title="收藏到书签，偶尔High一下^_^" rel="alternate" class="mw-harlem_shake_slow wobble shake" href="javascript:void(0)" onclick="javascript:(function go() {function c() {var e = document.createElement('link');e.setAttribute('type', 'text/css');e.setAttribute('rel', 'stylesheet');e.setAttribute('href', f);e.setAttribute('class', l);document.body.appendChild(e)}function h(){var e = document.getElementsByClassName(l);for(var t = 0; t< e.length; t++){document.body.removeChild(e[t])}}function p(){var e = document.createElement('div');e.setAttribute('class', a);document.body.appendChild(e);setTimeout(function(){document.body.removeChild(e)},100)}function d(e){return{height:e.offsetHeight,width:e.offsetWidth}}function v(i){var s = d(i);return s.height>e &amp;&amp;s.height<n &amp;&amp; s.width>t &amp;&amp;s.width<r}function m(e){var t=e;var n=0;while(!!t){n+=t.offsetTop;t=t.offsetParent}return n}function g(){var e=document.documentElement;if(!!window.innerWidth){return window.innerHeight}else if(e &amp;&amp; !isNaN(e.clientHeight)){return e.clientHeight}return 0}function y(){if(window.pageYOffset){return window.pageYOffset}return Math.max(document.documentElement.scrollTop,document.body.scrollTop)}function E(e){var t=m(e);return t>=w &amp;&amp; t<=b+w}var songs=['https://www.liaofuzhan.com/music/无尽光芒.mp3'];function S(){var e=document.getElementById('audio_element_id');if(e!=null){var index=parseInt(e.getAttribute('curSongIndex'));if(index>songs.length-2){index=0;}else{index++;}e.setAttribute('curSongIndex',index);N();}e.src=i;e.play()}function x(e){e.className+=' '+s+' '+o}function T(e){e.className+=' '+s+' '+u[Math.floor(Math.random()*u.length)]}function N(){var e=document.getElementsByClassName(s);var t=new RegExp('\\b'+s+'\\b');for(var n=0;n<e.length;){e[n].className=e[n].className.replace(t,'')}}function initAudioEle(){var e=document.getElementById('audio_element_id');if(e===null){e=document.createElement('audio');e.setAttribute('class',l);e.setAttribute('curSongIndex',0);e.id='audio_element_id';e.loop=false;e.bgcolor=0;e.addEventListener('canplay',function(){setTimeout(function(){x(k)},500);setTimeout(function(){N();p();for(var e=0;e<O.length;e++){T(O[e])}},15500)},true);e.addEventListener('ended',function(){N();h();go();},true);e.innerHTML='<p>If you are reading this,it is because your browser does not support the audio element. We recommend that you get a new browser.</p><p>';document.body.appendChild(e);}}initAudioEle();var e=30;var t=30;var n=350;var r=350;var curSongIndex=parseInt(document.getElementById('audio_element_id').getAttribute('curSongIndex'));var i=songs[curSongIndex];var s='mw-harlem_shake_me';var o='im_first';var u=['im_drunk','im_baked','im_trippin','im_blown'];var a='mw-strobe_light';var f='https://s3.amazonaws.com/moovweb-marketing/playground/harlem-shake-style.css';var l='mw_added_css';var b=g();var w=y();var C=document.getElementsByTagName('*');var k=null;for(var L=0;L<C.length;L++){var A=C[L];if(v(A)){if(E(A)){k=A;break}}}if(A===null){console.warn('Could not find a node of the right size. Please try a different page.');return}c();S();var O=[];for(var L=0;L<C.length;L++){var A=C[L];if(v(A)){O.push(A)}}})()"><i class="fa fa-music"></i> High~</a>

            </div>
          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a rel="external nofollow" href="https://github.com/ShaunSheep" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i></a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a rel="external nofollow" href="mailto:zuogewoniu@qq.com" target="_blank" title="E-Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i></a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a rel="external nofollow" href="https://www.douban.com/people/jincheng-ycf/" target="_blank" title="豆瓣">
                      
                        <i class="fa fa-fw fa-stack-overflow"></i></a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a rel="external nofollow" href="https://www.zhihu.com/people/OscarWildeHawking" target="_blank" title="知乎">
                      
                        <i class="fa fa-fw fa-instagram"></i></a>
                  </span>
                
            </div>
          

            <!--
            <div id="music163player">
                <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=1336790004&auto=1&height=66"></iframe>
            </div>
            -->

          
          

          
          

          <!--近期文章版块 began-->
          
              <div class="links-of-blogroll motion-element links-of-blogroll-block">
                <div class="links-of-blogroll-title">
                  <i class="fa fa-history fa-" aria-hidden="true"></i>
                  近期文章
                </div>
                <ul class="links-of-blogroll-list">
                  
                  
                    <li class='my-links-of-blogroll-li'>
                      <a href="/blog/2021/05/The-most-comprehensive-thinking-of-crash-practice-strategy/" title="Android Crash实践策略最全面思考" target="_blank">Android Crash实践策略最全面思考</a>
                    </li>
                  
                    <li class='my-links-of-blogroll-li'>
                      <a href="/blog/2021/05/android-crash-who-kill-you/" title="Android Crash揭秘与实践" target="_blank">Android Crash揭秘与实践</a>
                    </li>
                  
                    <li class='my-links-of-blogroll-li'>
                      <a href="/blog/2021/04/Career-stability-experience/" title="职业稳定性杂谈" target="_blank">职业稳定性杂谈</a>
                    </li>
                  
                    <li class='my-links-of-blogroll-li'>
                      <a href="/blog/2021/02/mtk-log/" title="mtk-log" target="_blank">mtk-log</a>
                    </li>
                  
                    <li class='my-links-of-blogroll-li'>
                      <a href="/blog/2021/02/android-bugfree-three-lines/" title="BugFree三剑客异常、日志、工具" target="_blank">BugFree三剑客异常、日志、工具</a>
                    </li>
                  
                </ul>
              </div>
          
          <!--近期文章版块 end-->

          
              <!-- canvas粒子时钟 -->
              <!-- canvas粒子时钟 https://www.cnblogs.com/xiaohuochai/p/6368039.html
  https://www.html5tricks.com/html5-canvas-dance-time.html
 -->
<div id="">
  <canvas id="canvas" style="width:60%;">
</div>
<script async>
(function(){
  var WINDOW_WIDTH = 820;
  		var WINDOW_HEIGHT = 250;
  		var RADIUS = 7; //球半径
  		var NUMBER_GAP = 10; //数字之间的间隙
  		var u=0.65; //碰撞能量损耗系数
  		var context; //Canvas绘制上下文
  		var balls = []; //存储彩色的小球
  		const colors = ["#33B5E5","#0099CC","#AA66CC","#9933CC","#99CC00","#669900","#FFBB33","#FF8800","#FF4444","#CC0000"]; //彩色小球的颜色
  		var currentNums = []; //屏幕显示的8个字符
  		var digit =
                  [
                      [
                          [0,0,1,1,1,0,0],
                          [0,1,1,0,1,1,0],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [0,1,1,0,1,1,0],
                          [0,0,1,1,1,0,0]
                      ],//0
                      [
                          [0,0,0,1,1,0,0],
                          [0,1,1,1,1,0,0],
                          [0,0,0,1,1,0,0],
                          [0,0,0,1,1,0,0],
                          [0,0,0,1,1,0,0],
                          [0,0,0,1,1,0,0],
                          [0,0,0,1,1,0,0],
                          [0,0,0,1,1,0,0],
                          [0,0,0,1,1,0,0],
                          [1,1,1,1,1,1,1]
                      ],//1
                      [
                          [0,1,1,1,1,1,0],
                          [1,1,0,0,0,1,1],
                          [0,0,0,0,0,1,1],
                          [0,0,0,0,1,1,0],
                          [0,0,0,1,1,0,0],
                          [0,0,1,1,0,0,0],
                          [0,1,1,0,0,0,0],
                          [1,1,0,0,0,0,0],
                          [1,1,0,0,0,1,1],
                          [1,1,1,1,1,1,1]
                      ],//2
                      [
                          [1,1,1,1,1,1,1],
                          [0,0,0,0,0,1,1],
                          [0,0,0,0,1,1,0],
                          [0,0,0,1,1,0,0],
                          [0,0,1,1,1,0,0],
                          [0,0,0,0,1,1,0],
                          [0,0,0,0,0,1,1],
                          [0,0,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [0,1,1,1,1,1,0]
                      ],//3
                      [
                          [0,0,0,0,1,1,0],
                          [0,0,0,1,1,1,0],
                          [0,0,1,1,1,1,0],
                          [0,1,1,0,1,1,0],
                          [1,1,0,0,1,1,0],
                          [1,1,1,1,1,1,1],
                          [0,0,0,0,1,1,0],
                          [0,0,0,0,1,1,0],
                          [0,0,0,0,1,1,0],
                          [0,0,0,1,1,1,1]
                      ],//4
                      [
                          [1,1,1,1,1,1,1],
                          [1,1,0,0,0,0,0],
                          [1,1,0,0,0,0,0],
                          [1,1,1,1,1,1,0],
                          [0,0,0,0,0,1,1],
                          [0,0,0,0,0,1,1],
                          [0,0,0,0,0,1,1],
                          [0,0,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [0,1,1,1,1,1,0]
                      ],//5
                      [
                          [0,0,0,0,1,1,0],
                          [0,0,1,1,0,0,0],
                          [0,1,1,0,0,0,0],
                          [1,1,0,0,0,0,0],
                          [1,1,0,1,1,1,0],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [0,1,1,1,1,1,0]
                      ],//6
                      [
                          [1,1,1,1,1,1,1],
                          [1,1,0,0,0,1,1],
                          [0,0,0,0,1,1,0],
                          [0,0,0,0,1,1,0],
                          [0,0,0,1,1,0,0],
                          [0,0,0,1,1,0,0],
                          [0,0,1,1,0,0,0],
                          [0,0,1,1,0,0,0],
                          [0,0,1,1,0,0,0],
                          [0,0,1,1,0,0,0]
                      ],//7
                      [
                          [0,1,1,1,1,1,0],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [0,1,1,1,1,1,0],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [0,1,1,1,1,1,0]
                      ],//8
                      [
                          [0,1,1,1,1,1,0],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [0,1,1,1,0,1,1],
                          [0,0,0,0,0,1,1],
                          [0,0,0,0,0,1,1],
                          [0,0,0,0,1,1,0],
                          [0,0,0,1,1,0,0],
                          [0,1,1,0,0,0,0]
                      ],//9
                      [
                          [0,0,0,0],
                          [0,0,0,0],
                          [0,1,1,0],
                          [0,1,1,0],
                          [0,0,0,0],
                          [0,0,0,0],
                          [0,1,1,0],
                          [0,1,1,0],
                          [0,0,0,0],
                          [0,0,0,0]
                      ]//:
                  ];

  		function drawDatetime(cxt){
  			var nums = [];

  			context.fillStyle="#005eac"
  			var date = new Date();
  			var offsetX = 70, offsetY = 30;
  			var hours = date.getHours();
  			var num1 = Math.floor(hours/10);
  			var num2 = hours%10;
  			nums.push({num: num1});
  			nums.push({num: num2});
  			nums.push({num: 10}); //冒号
  			var minutes = date.getMinutes();
  			var num1 = Math.floor(minutes/10);
  			var num2 = minutes%10;
  			nums.push({num: num1});
  			nums.push({num: num2});
  			nums.push({num: 10}); //冒号
  			var seconds = date.getSeconds();
  			var num1 = Math.floor(seconds/10);
  			var num2 = seconds%10;
  			nums.push({num: num1});
  			nums.push({num: num2});

  			for(var x = 0;x<nums.length;x++){
  				nums[x].offsetX = offsetX;
  				offsetX = drawSingleNumber(offsetX,offsetY, nums[x].num,cxt);
  				//两个数字连一块，应该间隔一些距离
  				if(x<nums.length-1){
  					if((nums[x].num!=10) &&(nums[x+1].num!=10)){
  						offsetX+=NUMBER_GAP;
  					}
  				}
  			}

  			//说明这是初始化
  			if(currentNums.length ==0){
  				currentNums = nums;
  			}else{
  				//进行比较
  				for(var index = 0;index<currentNums.length;index++){
  					if(currentNums[index].num!=nums[index].num){
  						//不一样时，添加彩色小球
  						addBalls(nums[index]);
  						currentNums[index].num=nums[index].num;
  					}
  				}
  			}
  			renderBalls(cxt);
  			updateBalls();

  			return date;
  		}

  		function addBalls (item) {
  			var num = item.num;
  			var numMatrix = digit[num];
  			for(var y = 0;y<numMatrix.length;y++){
  				for(var x = 0;x<numMatrix[y].length;x++){
  					if(numMatrix[y][x]==1){
  						var ball={
  							offsetX:item.offsetX+RADIUS+RADIUS*2*x,
  							offsetY:30+RADIUS+RADIUS*2*y,
  							color:colors[Math.floor(Math.random()*colors.length)],
  							g:1.5+Math.random(),
  							vx:Math.pow(-1, Math.ceil(Math.random()*10))*4+Math.random(),
  							vy:-5
  						}
  						balls.push(ball);
  					}
  				}
  			}
  		}

  		function renderBalls(cxt){
  			for(var index = 0;index<balls.length;index++){
  				cxt.beginPath();
  				cxt.fillStyle=balls[index].color;
  				cxt.arc(balls[index].offsetX, balls[index].offsetY, RADIUS, 0, 2*Math.PI);
  				cxt.fill();
  			}
  		}

  		function updateBalls () {
  			var i =0;
  			for(var index = 0;index<balls.length;index++){
  				var ball = balls[index];
  				ball.offsetX += ball.vx;
  				ball.offsetY += ball.vy;
  				ball.vy+=ball.g;
  				if(ball.offsetY > (WINDOW_HEIGHT-RADIUS)){
  					ball.offsetY= WINDOW_HEIGHT-RADIUS;
  					ball.vy=-ball.vy*u;
  				}
  				if(ball.offsetX>RADIUS&&ball.offsetX<(WINDOW_WIDTH-RADIUS)){

  					balls[i]=balls[index];
  					i++;
  				}
  			}
  			//去除出边界的球
  			for(;i<balls.length;i++){
  				balls.pop();
  			}
  		}
  		function drawSingleNumber(offsetX, offsetY, num, cxt){
  			var numMatrix = digit[num];
  			for(var y = 0;y<numMatrix.length;y++){
  				for(var x = 0;x<numMatrix[y].length;x++){
  					if(numMatrix[y][x]==1){
  						cxt.beginPath();
  						cxt.arc(offsetX+RADIUS+RADIUS*2*x,offsetY+RADIUS+RADIUS*2*y,RADIUS,0,2*Math.PI);
  						cxt.fill();
  					}
  				}
  			}
  			cxt.beginPath();
  			offsetX += numMatrix[0].length*RADIUS*2;
  			return offsetX;
  		}

  		var canvas = document.getElementById("canvas");
  		canvas.width=WINDOW_WIDTH;
  		canvas.height=WINDOW_HEIGHT;
  		context = canvas.getContext("2d");

  		//记录当前绘制的时刻
  		var currentDate = new Date();

  		setInterval(function(){
  			//清空整个Canvas，重新绘制内容
  			context.clearRect(0, 0, context.canvas.width, context.canvas.height);
  			drawDatetime(context);
  		}, 50)
})();
</script>

          
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%BB%84%E4%BB%B6%E5%8C%96%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5"><span class="nav-number">1.</span> <span class="nav-text">组件化基本概念</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#gradle%E5%B1%9E%E6%80%A7%E6%96%87%E4%BB%B6"><span class="nav-number">1.1.</span> <span class="nav-text">gradle属性文件</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#gradleproperties"><span class="nav-number">1.1.1.</span> <span class="nav-text">gradle.properties</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#localproperties"><span class="nav-number">1.1.2.</span> <span class="nav-text">local.properties</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E9%A1%B6%E5%B1%82buildgradle"><span class="nav-number">1.2.</span> <span class="nav-text">顶层build.gradle</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%9B%B4%E6%8E%A5%E9%85%8D%E7%BD%AE"><span class="nav-number">1.2.1.</span> <span class="nav-text">直接配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%A4%96%E9%83%A8%E5%AF%BC%E5%85%A5"><span class="nav-number">1.2.2.</span> <span class="nav-text">外部导入</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%A8%A1%E5%9D%97%E7%BA%A7buildgradle"><span class="nav-number">1.3.</span> <span class="nav-text">模块级build.gradle</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%BA%90%E4%BB%A3%E7%A0%81%E9%9B%86sourceset"><span class="nav-number">1.4.</span> <span class="nav-text">源代码集Sourceset</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%BB%84%E4%BB%B6%E5%8C%96%E5%AE%9E%E8%B7%B5"><span class="nav-number">2.</span> <span class="nav-text">组件化实践</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%BB%84%E4%BB%B6%E5%8C%96%E7%9B%AE%E6%A0%87"><span class="nav-number">2.1.</span> <span class="nav-text">组件化目标</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%BB%84%E4%BB%B6%E5%8C%96%E6%AD%A5%E9%AA%A4"><span class="nav-number">2.2.</span> <span class="nav-text">组件化步骤</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%A0%B9%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84"><span class="nav-number">2.3.</span> <span class="nav-text">根目录结构</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#buildgradle"><span class="nav-number">2.3.1.</span> <span class="nav-text">build.gradle</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#configgradle"><span class="nav-number">2.3.2.</span> <span class="nav-text">config.gradle</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#gradle%E5%B1%9E%E6%80%A7%E6%96%87%E4%BB%B6"><span class="nav-number">2.3.3.</span> <span class="nav-text">gradle属性文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#modulebuildgradle"><span class="nav-number">2.3.4.</span> <span class="nav-text">module.build.gradle</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#settinggradle"><span class="nav-number">2.3.5.</span> <span class="nav-text">setting.gradle</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#module-news"><span class="nav-number">2.4.</span> <span class="nav-text">module-news</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#buildgradle"><span class="nav-number">2.4.1.</span> <span class="nav-text">build.gradle</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#moduleandroidmanifestxml"><span class="nav-number">2.4.2.</span> <span class="nav-text">module&#x2F;AndroidManifest.xml</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#androidmanifestxml"><span class="nav-number">2.4.3.</span> <span class="nav-text">AndroidManifest.xml</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#lib-common-ui"><span class="nav-number">2.5.</span> <span class="nav-text">lib-common-ui</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#moduleandroidmanifestxml"><span class="nav-number">2.5.1.</span> <span class="nav-text">module&#x2F;AndroidManifest.xml</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#androidmanifestxml"><span class="nav-number">2.5.2.</span> <span class="nav-text">AndroidManifest.xml</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#buildgradle"><span class="nav-number">2.5.3.</span> <span class="nav-text">build.gradle</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#app-vip"><span class="nav-number">2.6.</span> <span class="nav-text">app-vip</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#androidmanifestxml"><span class="nav-number">2.6.1.</span> <span class="nav-text">AndroidManifest.xml</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#buildgradle"><span class="nav-number">2.6.2.</span> <span class="nav-text">build.gradle</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#app-normal"><span class="nav-number">2.7.</span> <span class="nav-text">app-normal</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#androidmanifestxml"><span class="nav-number">2.7.1.</span> <span class="nav-text">AndroidManifest.xml</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#buildgradle"><span class="nav-number">2.7.2.</span> <span class="nav-text">build.gradle</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%9E%E8%B7%B5%E6%80%BB%E7%BB%93"><span class="nav-number">2.8.</span> <span class="nav-text">实践总结</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%BB%84%E4%BB%B6%E5%8C%96%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9"><span class="nav-number">3.</span> <span class="nav-text">组件化注意事项</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%BB%84%E4%BB%B6%E5%8C%96%E6%8A%80%E6%9C%AF%E9%80%89%E5%9E%8B"><span class="nav-number">4.</span> <span class="nav-text">组件化技术选型</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%BB%84%E4%BB%B6%E5%8C%96%E5%8F%82%E8%80%83%E6%96%87%E7%AB%A0"><span class="nav-number">5.</span> <span class="nav-text">组件化参考文章</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

      

      <!-- 标签云 -->
      <!--
      
      <script type="text/javascript" charset="utf-8" src="/js/tagcloud.js"></script>
      <script type="text/javascript" charset="utf-8" src="/js/tagcanvas.js"></script>
      <div class="widget-wrap">
      <h3 class="widget-title">Tag Cloud</h3>
      <div id="myCanvasContainer" class="widget tagcloud">
          <canvas width="250" height="250" id="resCanvas" style="width=100%">
              <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/Android/" rel="tag">Android</a><span class="tag-list-count">13</span></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/AndroidUI%E4%BC%98%E5%8C%96/" rel="tag">AndroidUI优化</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/Android%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96/" rel="tag">Android性能优化</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/BugFree/" rel="tag">BugFree</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/Communication/" rel="tag">Communication</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/Handler/" rel="tag">Handler</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/Performance/" rel="tag">Performance</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/%E4%B8%AA%E4%BA%BA%E6%95%99%E8%82%B2/" rel="tag">个人教育</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/%E5%AD%A6%E4%B9%A0%E6%96%B9%E6%B3%95/" rel="tag">学习方法</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/%E5%BC%80%E6%BA%90%E6%A1%86%E6%9E%B6/" rel="tag">开源框架</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/%E6%8A%80%E6%9C%AF%E9%80%89%E5%9E%8B/" rel="tag">技术选型</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/%E6%9D%82%E8%B0%88/" rel="tag">杂谈</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/%E7%A8%8B%E5%BA%8F%E4%BA%BA%E7%94%9F%EF%BC%8C%E6%9D%82%E8%B0%88/" rel="tag">程序人生，杂谈</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/%E7%AE%97%E6%B3%95/" rel="tag">算法</a><span class="tag-list-count">1</span></li></ul>
          </canvas>
      </div>
      </div>
      
      -->
      <!-- 标签云 -->

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<div class="copyright">&copy; 2015 &mdash; <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
       <i class="fa fa-heartbeat"></i>
  </span>
  <!--
    <span class="author" itemprop="copyrightHolder"> &nbsp;叶金诚</span>
  -->
  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">Site words total count&#58;</span>
    
    <span title="Site words total count">111k</span>
  
</div>














  <script src='https://unpkg.com/mermaid@7.1.2/dist/mermaid.min.js'></script>
  <script>
    if (window.mermaid) {
      mermaid.initialize("");
    }
  </script>



        
<div class="busuanzi-count">
  <!--
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
  -->
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

   

  
  
    
      <span class="site-uv">
        
        我的第 <span class="busuanzi-value" id="busuanzi_value_site_uv"></span> 位朋友，
      </span>
    

    
      <span class="site-pv">
        历经 <span class="busuanzi-value" id="busuanzi_value_site_pv"></span> 次回眸才与你相遇
        <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      </span>
    
  

</div>








        
      </div>
    </footer>

    
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  










  



  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/npm/jquery@2.1.3/dist/jquery.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/fastclick/1.0.6/fastclick.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazyload/1.9.3/jquery.lazyload.min.js"></script>
  

  
  
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/velocity-animate@1.2.1/velocity.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/npm/velocity-animate@1.2.1/velocity.ui.min.js"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script id="ribbon" type="text/javascript" size="60" alpha="0.1"  zIndex="-1" src="/blog/lib/canvas-ribbon/canvas-ribbon.js"></script>
  


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/blog/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/blog/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/blog/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  
    <script type="text/javascript">
      (function(d, s) {
        var j, e = d.getElementsByTagName(s)[0];
        if (typeof LivereTower === 'function') { return; }
        j = d.createElement(s);
        j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
        j.async = true;
        e.parentNode.insertBefore(j, e);
      })(document, 'script');
    </script>
  















  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/blog/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





    <script>  function addCount(Counter){var $visitors=$('.leancloud_visitors');var url=$visitors.attr('id').trim();var title=$visitors.attr('data-flag-title').trim();Counter('get','/classes/Counter',{where:JSON.stringify({url})}).done(function({results}){if(results.length>0){var counter=results[0]; var $element=$(document.getElementById(url));$element.find('.leancloud-visitors-count').text(counter.time+1);Counter('put','/classes/Counter/'+counter.objectId,JSON.stringify({time:{'__op':'Increment','amount':1}})) .fail(function({responseJSON}){console.log('Failed to save Visitor num, with error message: '+responseJSON.error);})}else{ Counter('post','/classes/Counter',JSON.stringify({title:title,url:url,time:1})).done(function(){var $element=$(document.getElementById(url));$element.find('.leancloud-visitors-count').text(1);}).fail(function(){console.log('Failed to create');});}}).fail(function({responseJSON}){console.log('LeanCloud Counter Error: '+responseJSON.code+' '+responseJSON.error);});}$(function(){$.get('https://app-router.leancloud.cn/2/route?appId='+'MFn6psRe8xtnq9sq6lv9MJks-gzGzoHsz').done(function({api_server}){var Counter=function(method,url,data){return $.ajax({method:method,url:'https://'+api_server+'/1.1'+url,headers:{'X-LC-Id':'MFn6psRe8xtnq9sq6lv9MJks-gzGzoHsz','X-LC-Key':'pi8Pa2aH3XpcaovMyqIXVuOP','Content-Type':'application/json',},data:data});};  const localhost=/http:\/\/(localhost|127.0.0.1|0.0.0.0)/;if(localhost.test(document.URL))return;addCount(Counter);});});</script>

  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  
  
  
  <link rel="stylesheet" href="/blog/lib/needsharebutton/needsharebutton.css">

  
  
  <script src="/blog/lib/needsharebutton/needsharebutton.js"></script>

  <script>
    
      pbOptions = {};
      
          pbOptions.iconStyle = "default";
      
          pbOptions.boxForm = "horizontal";
      
          pbOptions.position = "bottomCenter";
      
          pbOptions.networks = "Weibo,Wechat,Douban,QQZone,Twitter,Facebook";
      
      new needShareButton('#needsharebutton-postbottom', pbOptions);
    
    
  </script>

  

  
  


  

  


  <!-- Tidio 在线联系功能、鼠标点击特效、页面反馈...-->
  <script type="text/javascript" src="/js/src/clipboard.min.js"></script>
<script type="text/javascript" src="/js/src/clipboard-use.js"></script>



  
    <canvas class="fireworks" style="position: fixed;left: 0;top: 0;z-index: 1; pointer-events: none;" ></canvas>
    <script async src="//cdn.bootcss.com/animejs/2.2.0/anime.min.js"></script>
    <script async src="/js/cursor/explosion.min.js"></script>
  










  <script src="/js/src/activate-power-mode.min.js"></script>
  <script>
    POWERMODE.colorful = true;
    POWERMODE.shake = false;
    document.body.addEventListener('input', POWERMODE);
  </script>






  <script async language="javascript">

    var div = document.createElement("div");
    //插入到自定义的theme-info或者copyright之后
    var copyright = document.querySelector(".theme-info2") || document.querySelector(".copyright");

    function show_run_time(){
        window.setTimeout("show_run_time()", 1000);
      // BirthDay=new Date("08/07/2019 20:00:00");
        BirthDay=new Date("08/07/2016 20:00:00");
        today=new Date();
        timeold=(today.getTime()-BirthDay.getTime());
        sectimeold=timeold/1000
        secondsold=Math.floor(sectimeold);
        msPerDay=24*60*60*1000
        e_daysold=timeold/msPerDay
        daysold=Math.floor(e_daysold);
        e_hrsold=(e_daysold-daysold)*24;
        hrsold=setzero(Math.floor(e_hrsold));
        e_minsold=(e_hrsold-hrsold)*60;
        minsold=setzero(Math.floor((e_hrsold-hrsold)*60));
        seconds=setzero(Math.floor((e_minsold-minsold)*60));

        // 使用zh-Hans.yml的文字替换
        div.innerHTML = "我已在此等候你 " + "<span style='color: #1890ff'> " + daysold + " </span> 天 <span style='color: #1890ff'>" + hrsold + " </span>时 <span style='color: #1890ff'>" + minsold + " </span>分 <span style='color: #1890ff'>" + seconds + " </span>秒 ";

        document.querySelector(".footer-inner").insertBefore(div, copyright.nextSibling);

    }
    function setzero(i){
        if (i<10)
        {i="0" + i};
        return i;
    }

    show_run_time();

  </script>




<!-- 旋转魔方 -->

   
      
<style>
  /*最外层容器样式*/
  .wrap {
    width: 0px;
    height: 0px;
    /*margin: 80px;*/
    /*position: relative;*/
	     /*显示位置*/
    position: fixed;
    bottom: 120px;
    right: 240px;
    z-index: 999;
  }

  /*包裹所有容器样式*/
  .cube {
    width: 0px;
    height: 0px;
    margin: 0 auto;
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    transform: rotateX(-30deg) rotateY(-80deg);
    animation: rotate linear 10s infinite;
  }

  @-webkit-keyframes rotate {
    from {
      transform: rotateX(0deg) rotateY(0deg);
    }
    to {
      transform: rotateX(360deg) rotateY(360deg);
    }
  }

  .cube div {
    position: absolute;
    width: 50px;
    height: 50px;
    opacity: 0.8;
    transition: all .4s;
  }

  /*定义所有图片样式*/
  .pic {
    width: 50px;
    height: 50px;
  }

  .cube .out_front {
    transform: rotateY(0deg) translateZ(25px);
  }

  .cube .out_back {
    transform: translateZ(-25px) rotateY(180deg);
  }

  .cube .out_left {
    transform: rotateY(-90deg) translateZ(25px);
  }

  .cube .out_right {
    transform: rotateY(90deg) translateZ(25px);
  }

  .cube .out_top {
    transform: rotateX(90deg) translateZ(25px);
  }

  .cube .out_bottom {
    transform: rotateX(-90deg) translateZ(25px);
  }

  /*定义小正方体样式*/
  .cube span {
    display: block;
    width: 25px;
    height: 25px;
    position: absolute;
    top: 12px;
    left: 12px;
  }

  .cube .in_pic {
    width: 25px;
    height:25px;
  }

  .cube .in_front {
    transform: rotateY(0deg) translateZ(12px);
  }

  .cube .in_back {
    transform: translateZ(-12px) rotateY(180deg);
  }

  .cube .in_left {
    transform: rotateY(-90deg) translateZ(12px);
  }

  .cube .in_right {
    transform: rotateY(90deg) translateZ(12px);
  }

  .cube .in_top {
    transform: rotateX(90deg) translateZ(12px);
  }

  .cube .in_bottom {
    transform: rotateX(-90deg) translateZ(12px);
  }

  /*鼠标移入后样式*/
  .cube:hover .out_front {
    transform: rotateY(0deg) translateZ(50px);
  }

  .cube:hover .out_back {
    transform: translateZ(-50px) rotateY(180deg);
  }

  .cube:hover .out_left {
    transform: rotateY(-90deg) translateZ(50px);
  }

  .cube:hover .out_right {
    transform: rotateY(90deg) translateZ(50px);
  }

  .cube:hover .out_top {
    transform: rotateX(90deg) translateZ(50px);
  }

  .cube:hover .out_bottom {
    transform: rotateX(-90deg) translateZ(50px);
  }
</style>

<div class="wrap">

		<!--包裹所有元素的容器-->
		<div class="cube">
			<!--前面图片 -->
			<div class="out_front">
			  <a onclick="back2top()">
				  <img src="http://cdn.yangchaofan.cn/BlogGifRes/20210307/lAq9mKTioPeO.png" class="pic" />
				</a>
			</div>
			<!--后面图片 -->
			<div class="out_back">
				<a onclick="back2top()">
          <img src="http://cdn.yangchaofan.cn/BlogGifRes/20210307/lAq9mKTioPeO.png" class="pic" />
        </a>
			</div>
			<!--左面图片 -->
			<div class="out_left">
        <a onclick="back2top()">
				  <img src="http://cdn.yangchaofan.cn/BlogGifRes/20210307/lAq9mKTioPeO.png" class="pic" />
				</a>
			</div>
			<!--右面图片 -->
			<div class="out_right">
				<a onclick="back2top()">
          <img src="http://cdn.yangchaofan.cn/BlogGifRes/20210307/lAq9mKTioPeO.png" class="pic" />
        </a>
			</div>
			<!--上面图片 -->
			<div class="out_top">
				<a onclick="back2top()">
          <img src="http://cdn.yangchaofan.cn/BlogGifRes/20210307/lAq9mKTioPeO.png" class="pic" />
        </a>
			</div>
			<!--下面图片 -->
			<div class="out_bottom">
				<a onclick="back2top()">
          <img src="http://cdn.yangchaofan.cn/BlogGifRes/20210307/lAq9mKTioPeO.png" class="pic" />
        </a>
			</div>

			<!--小正方体 -->
			<span class="in_front">
				<img src="https://s2.ax1x.com/2019/10/14/KptCPf.th.jpg" class="in_pic" />
			</span>
			<span class="in_back">
			     <img src="https://s2.ax1x.com/2019/10/14/KptCPf.th.jpg" class="in_pic" />
			</span>
			<span class="in_left">
				<img src="https://s2.ax1x.com/2019/10/14/KptCPf.th.jpg" class="in_pic" />
			</span>
			<span class="in_right">
				<img src="https://s2.ax1x.com/2019/10/14/KptCPf.th.jpg" class="in_pic" />
			</span>
			<span class="in_top">
				<img src="https://s2.ax1x.com/2019/10/14/KptCPf.th.jpg" class="in_pic" />
			</span>
			<span class="in_bottom">
				<img src="https://s2.ax1x.com/2019/10/14/KptCPf.th.jpg" class="in_pic" />
			</span>
		</div>

</div>

<script>
  function back2top(){
    $('html, body').animate({scrollTop: 0}, 500);
  }
</script>

   


<!-- Console 输出第三方个性化字体 -->

  <script async type="text/javascript" src="/blog/figlet/fetch.min.js"></script>
  <script type="text/javascript" src="/blog/figlet/figlet.js"></script>
  <script type="text/javascript">

      figlet.defaults({fontPath: "/figlet/fonts"});
      figlet("Welcome To Leaface", "Big Money-ne", function(err, text) {
          if (err) {
              console.log("something went wrong...");
              console.dir(err);
              return;
          }
          console.log(text);
      });
  </script>


  <!-- Console 输出自定义字体 -->
  
    <script async type="text/javascript">
        var text = "Welcome To Leaface";
        var date = '2021-06-10';
        console.log("%c " + text, "font-size:100px;color:white;border-radius:20px;height:200px; background:-webkit-linear-gradient(yellow,orange,red,green,blue,purple);text-shadow: 0 1px 0 #ccc,0 2px 0 #c9c9c9,0 3px 0 #bbb,0 4px 0 #b9b9b9,0 5px 0 #aaa,0 6px 1px rgba(0,0,0,.1),0 0 5px rgba(0,0,0,.1),0 1px 3px rgba(0,0,0,.3),0 3px 5px rgba(0,0,0,.2),0 5px 10px rgba(0,0,0,.25),0 10px 10px rgba(0,0,0,.2),0 20px 20px rgba(0,0,0,.15);");
        console.info('\n' + ' %c Leafae Site %c https://www.liaofuzhan.com ' + '\n', 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;');
        console.info('\n' + ' %c Leafae QQ %c 793458585 ' + '\n', 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;');
        console.info('\n' + ' %c Leafae Wechat %c leaface ' + '\n', 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;');
       // console.log("%c Time: " + date, "font-size:100px;white:"+fcolor+";border-radius:20px;height:200px; background:-webkit-linear-gradient(yellow,orange,red,green,blue,purple);text-shadow: 0 1px 0 #ccc,0 2px 0 #c9c9c9,0 3px 0 #bbb,0 4px 0 #b9b9b9,0 5px 0 #aaa,0 6px 1px rgba(0,0,0,.1),0 0 5px rgba(0,0,0,.1),0 1px 3px rgba(0,0,0,.3),0 3px 5px rgba(0,0,0,.2),0 5px 10px rgba(0,0,0,.25),0 10px 10px rgba(0,0,0,.2),0 20px 20px rgba(0,0,0,.15);  background-image: linear-gradient(to right, orangered, orange, gold, lightgreen, cyan, dodgerblue, mediumpurple, hotpink, orangered);");
       // console.log("%c .", "padding:300px 600px;line-height:10px;background:url(https://s2.ax1x.com/2019/10/17/KkoAJJ.md.png) no-repeat;");
    </script>
  


  <!-- 看板娘 -->
  
      <script async src="/live2d-widget/autoload.js"></script>
  
	<!-- leafacePlayer -->
	
	<script id="lfz" src="http://player.liaofuzhan.com/player/player.js" key=1368557075310858241></script>
	

  

  

  <!-- 代码块复制功能 -->
  <script async type="text/javascript" src="/js/src/clipboard.min.js"></script>
  <script async type="text/javascript" src="/js/src/clipboard-use.js"></script>
 

  <!--share.js-->
  <link async rel="stylesheet" href="/sharejs/css/share.min.css">
  <script async src="/sharejs/js/social-share.min.js"></script>

  <!-- 模仿知乎卡片样式链接、崩溃欺骗特效 -->
  <script async type="text/javascript" src="/js/src/linkcard.js"></script>

  <!--崩溃欺骗 放在js文件最后-->
  <!--
  <script type="text/javascript" src="/js/src/crash_cheat.js"></script>
  -->

 

<script src="/blog/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>
